We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ab5ef30 + 1defdb3 commit 0f187eaCopy full SHA for 0f187ea
1 file changed
src/index.js
@@ -82,21 +82,30 @@ const scriptLoader = (...scripts) => (WrappedComponent) => {
82
isScriptLoaded: false,
83
isScriptLoadSucceed: false
84
}
85
+
86
+ this._isMounted = false;
87
88
89
componentDidMount () {
90
+ this._isMounted = true;
91
startLoadingScripts(scripts, err => {
- this.setState({
- isScriptLoaded: true,
- isScriptLoadSucceed: !err
92
- }, () => {
93
- if (!err) {
94
- this.props.onScriptLoaded()
95
- }
96
- })
+ if(this._isMounted) {
+ this.setState({
+ isScriptLoaded: true,
+ isScriptLoadSucceed: !err
+ }, () => {
97
+ if (!err) {
98
+ this.props.onScriptLoaded()
99
+ }
100
+ })
101
102
})
103
104
105
+ componentWillUnmount () {
106
107
108
109
render () {
110
const props = {
111
...this.props,
0 commit comments