-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,9 @@ A React HOC for loading 3rd party scripts asynchronously. This HOC allows you to | |
- `removeOnUnmount`: *boolean* **default=false** : If set to `true` removes the script tag when component unmounts. | ||
|
||
#### HOC Component props | ||
``` | ||
```js | ||
const AsyncScriptComponent = makeAsyncScriptLoader(URL)(Component); | ||
--- | ||
// --- | ||
<AsyncScriptComponent asyncScriptOnLoad={callAfterScriptLoads} /> | ||
``` | ||
- `asyncScriptOnLoad`: *function* : called after script finishes loading. *using `script.onload`* | ||
|
@@ -35,7 +35,7 @@ const AsyncScriptComponent = makeAsyncScriptLoader(URL)(Component); | |
If you pass a `ref` prop you'll have access to your wrapped components instance. See the tests for detailed example. | ||
|
||
Simple Example: | ||
``` | ||
```js | ||
const AsyncHoc = makeAsyncScriptLoader(URL)(ComponentNeedsScript); | ||
|
||
class DisplayComponent extends React.Component { | ||
|
@@ -98,6 +98,25 @@ React.render( | |
); | ||
``` | ||
|
||
## Migration to 1.0 | ||
|
||
- Component is now passed as a second function call | ||
- removeOnMount is now removeOnUnmount (typo fixed!) | ||
- exposeFuncs is no longer needed as it's done automatically! | ||
|
||
```diff | ||
-export default makeAsyncScriptLoader(ReCAPTCHA, getURL, { | ||
+export default makeAsyncScriptLoader(getURL, { | ||
callbackName, | ||
globalName, | ||
- removeOnMount: initialOptions.removeOnMount || false, | ||
+ removeOnUnmount: initialOptions.removeOnUnmount || false, | ||
- exposeFuncs: ["getValue", "getWidgetId", "reset", "execute"], | ||
-}); | ||
+})(ReCAPTCHA); | ||
``` | ||
|
||
|
||
## Notes | ||
|
||
Pre `1.0.0` and - `React < [email protected]` support details in [0.11.1](https://github.com/dozoisch/react-async-script/tree/v0.11.1). | ||
|