Skip to content

Commit

Permalink
Merge pull request #40 from dozoisch/migration_readme
Browse files Browse the repository at this point in the history
Add migration notes in README
  • Loading branch information
dozoisch authored Aug 18, 2018
2 parents 2c1599f + a861662 commit e633c39
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`*
Expand All @@ -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 {
Expand Down Expand Up @@ -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 < React@16.4.1` support details in [0.11.1](https://github.com/dozoisch/react-async-script/tree/v0.11.1).
Expand Down

0 comments on commit e633c39

Please sign in to comment.