Skip to content

Commit e633c39

Browse files
authored
Merge pull request #40 from dozoisch/migration_readme
Add migration notes in README
2 parents 2c1599f + a861662 commit e633c39

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ A React HOC for loading 3rd party scripts asynchronously. This HOC allows you to
2020
- `removeOnUnmount`: *boolean* **default=false** : If set to `true` removes the script tag when component unmounts.
2121

2222
#### HOC Component props
23-
```
23+
```js
2424
const AsyncScriptComponent = makeAsyncScriptLoader(URL)(Component);
25-
---
25+
// ---
2626
<AsyncScriptComponent asyncScriptOnLoad={callAfterScriptLoads} />
2727
```
2828
- `asyncScriptOnLoad`: *function* : called after script finishes loading. *using `script.onload`*
@@ -35,7 +35,7 @@ const AsyncScriptComponent = makeAsyncScriptLoader(URL)(Component);
3535
If you pass a `ref` prop you'll have access to your wrapped components instance. See the tests for detailed example.
3636

3737
Simple Example:
38-
```
38+
```js
3939
const AsyncHoc = makeAsyncScriptLoader(URL)(ComponentNeedsScript);
4040

4141
class DisplayComponent extends React.Component {
@@ -98,6 +98,25 @@ React.render(
9898
);
9999
```
100100

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+
101120
## Notes
102121

103122
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

Comments
 (0)