Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async script load #61

Closed
Bogdaan opened this issue Nov 16, 2015 · 6 comments
Closed

Async script load #61

Bogdaan opened this issue Nov 16, 2015 · 6 comments

Comments

@Bogdaan
Copy link

Bogdaan commented Nov 16, 2015

Current "no-async" solution is too slow for mobile clients.
It posible to load library "async way" with callback?

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places&callback=initMap"
    async defer></script>
@ro-ka
Copy link
Contributor

ro-ka commented Nov 19, 2015

Did you try it out? What does not work?

@ro-ka
Copy link
Contributor

ro-ka commented Feb 5, 2016

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.

@ro-ka ro-ka closed this as completed Feb 5, 2016
@oyeanuj
Copy link
Contributor

oyeanuj commented Dec 4, 2016

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?

@ro-ka
Copy link
Contributor

ro-ka commented Dec 14, 2016

@oyeanuj Can you explain that a bit?

@oyeanuj
Copy link
Contributor

oyeanuj commented Dec 21, 2016

@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.

@ro-ka
Copy link
Contributor

ro-ka commented Jan 2, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants