Giter Site home page Giter Site logo

Async script load about react-geosuggest HOT 6 CLOSED

ubilabs avatar ubilabs commented on July 19, 2024
Async script load

from react-geosuggest.

Comments (6)

oyeanuj avatar oyeanuj commented on July 19, 2024 2

@ro-ka I was thinking out aloud but maybe along the lines of the options offered in react-google-maps. See usage here under the section 'Loading Libraries'.

Option 1
Have a prop passed in to ReactGeoSuggest called apiKey and handleScriptLoading, which if set lets ReactGeoSuggest deal with script loading (seems like the most straightforward!)

Option 2
Offer an optional component like <ReactGeoSuggestAsync /> which does the same as ReactGeoSuggest but wraps it up with a script loading HoC.

Which brings us to..

Option 3
Offer a HoC AsyncScriptLoad which accepts an apiKey prop, and sets gmapApiLoaded prop when the script is loaded.

Option 4
Do nothing :)

In full disclosure, I got it to work using react-async-script-loader but think that it would be cleaner , more consistent and easier for new users, if the library took care of it.

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

Did you try it out? What does not work?

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

Closing. You can mount the component in the callback.

As there may be many more components or things in a project using the Google Maps API, I won’t include loading of the API into this component.

from react-geosuggest.

oyeanuj avatar oyeanuj commented on July 19, 2024

You can mount the component in the callback.

@ro-ka What do you think of an optional async HoC, like being prepared in react-google-maps [1][2]?

@Bogdaan How did you finally end up implementing this in an async manner?

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

@oyeanuj Can you explain that a bit?

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

I’m still voting for Option 4. 😃 Not sure what I would prefer from a users POV…

from react-geosuggest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.