@@ -20,9 +20,9 @@ A React HOC for loading 3rd party scripts asynchronously. This HOC allows you to
20
20
- ` removeOnUnmount ` : * boolean* ** default=false** : If set to ` true ` removes the script tag when component unmounts.
21
21
22
22
#### HOC Component props
23
- ```
23
+ ``` js
24
24
const AsyncScriptComponent = makeAsyncScriptLoader (URL )(Component);
25
- ---
25
+ // ---
26
26
< AsyncScriptComponent asyncScriptOnLoad= {callAfterScriptLoads} / >
27
27
```
28
28
- ` asyncScriptOnLoad ` : * function* : called after script finishes loading. * using ` script.onload ` *
@@ -35,7 +35,7 @@ const AsyncScriptComponent = makeAsyncScriptLoader(URL)(Component);
35
35
If you pass a ` ref ` prop you'll have access to your wrapped components instance. See the tests for detailed example.
36
36
37
37
Simple Example:
38
- ```
38
+ ``` js
39
39
const AsyncHoc = makeAsyncScriptLoader (URL )(ComponentNeedsScript);
40
40
41
41
class DisplayComponent extends React .Component {
@@ -98,6 +98,25 @@ React.render(
98
98
);
99
99
```
100
100
101
+ ## Migration to 1.0
102
+
103
+ - Component is now passed as a second function call
104
+ - removeOnMount is now removeOnUnmount (typo fixed!)
105
+ - exposeFuncs is no longer needed as it's done automatically!
106
+
107
+ ``` diff
108
+ - export default makeAsyncScriptLoader(ReCAPTCHA, getURL, {
109
+ + export default makeAsyncScriptLoader(getURL, {
110
+ callbackName,
111
+ globalName,
112
+ - removeOnMount: initialOptions.removeOnMount || false,
113
+ + removeOnUnmount: initialOptions.removeOnUnmount || false,
114
+ - exposeFuncs: ["getValue", "getWidgetId", "reset", "execute"],
115
+ - });
116
+ + })(ReCAPTCHA);
117
+ ```
118
+
119
+
101
120
## Notes
102
121
103
122
Pre ` 1.0.0 ` and - ` React < React@16.4.1 ` support details in [ 0.11.1] ( https://github.com/dozoisch/react-async-script/tree/v0.11.1 ) .
0 commit comments