dozoisch / dozoisch/react-async-script

Setting component to rerender when script loaded

Open
#50 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
177
Forks
29
PR merge metrics
No merged PRs in 30d

Description

Currently I have a component: QuickAdd that needs the google autocomplete api to run

However, while the component renders, it doesn't seem like the autocomplete has finished loading. If i go to another component and then return to the QuickAdd component then it works, which makes me think it needs to rerender after the script is loaded.

The globalName is always passed as a prop and but is always undefined. What other listener can i use for this?

`const callbackName = "onloadcallback";
const globalName = "quickAddLoader";
const url = `https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places`;
const AsyncHoc = makeAsyncScriptLoader(url, {globalName: globalName})(QuickAdd);
export default AsyncHoc; `

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.