async-render
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -41,9 +41,3 @@ 'use strict'; | ||
value: function componentDidMount() { | ||
var _this2 = this; | ||
var children = this.props.children; | ||
this.idleCallbackId = requestIdleCallback(function () { | ||
return _this2.setState({ children: children }); | ||
}); | ||
this.requestIdleCallback(); | ||
} | ||
@@ -53,4 +47,2 @@ }, { | ||
value: function componentDidUpdate(prevProps, prevState, snapshot) { | ||
var _this3 = this; | ||
var children = this.props.children; | ||
@@ -60,8 +52,27 @@ | ||
this.cancelIdleCallback(); | ||
this.idleCallbackId = requestIdleCallback(function () { | ||
return _this3.setState({ children: children }); | ||
}); | ||
this.requestIdleCallback(); | ||
} | ||
} | ||
}, { | ||
key: 'requestIdleCallback', | ||
value: function (_requestIdleCallback) { | ||
function requestIdleCallback() { | ||
return _requestIdleCallback.apply(this, arguments); | ||
} | ||
requestIdleCallback.toString = function () { | ||
return _requestIdleCallback.toString(); | ||
}; | ||
return requestIdleCallback; | ||
}(function () { | ||
var _this2 = this; | ||
var children = this.props.children; | ||
this.idleCallbackId = requestIdleCallback(function () { | ||
return _this2.setState({ children: children }); | ||
}); | ||
}) | ||
}, { | ||
key: 'cancelIdleCallback', | ||
@@ -68,0 +79,0 @@ value: function (_cancelIdleCallback) { |
{ | ||
"name": "async-render", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "React Component with *requestIdleCallback*.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -15,4 +15,3 @@ /** | ||
componentDidMount(){ | ||
let { children } = this.props; | ||
this.idleCallbackId = requestIdleCallback(()=>this.setState({ children })); | ||
this.requestIdleCallback(); | ||
} | ||
@@ -23,5 +22,9 @@ componentDidUpdate(prevProps, prevState, snapshot){ | ||
this.cancelIdleCallback(); | ||
this.idleCallbackId = requestIdleCallback(()=>this.setState({ children })); | ||
this.requestIdleCallback(); | ||
} | ||
} | ||
requestIdleCallback(){ | ||
let { children } = this.props; | ||
this.idleCallbackId = requestIdleCallback(()=>this.setState({ children })); | ||
} | ||
cancelIdleCallback(){ | ||
@@ -28,0 +31,0 @@ if(this.idleCallbackId){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62048
126