react-lifecycles-compat
Advanced tools
Comparing version 1.1.3 to 1.1.4
{ | ||
"name": "react-lifecycles-compat", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Backwards compatibility polyfill for React class components", | ||
@@ -5,0 +5,0 @@ "main": "react-lifecycles-compat.cjs.js", |
@@ -35,2 +35,3 @@ 'use strict'; | ||
this.state = nextState; | ||
this.__reactInternalSnapshotFlag = true; | ||
this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate( | ||
@@ -95,7 +96,13 @@ prevProps, | ||
) { | ||
// 16.3+ will pass a snapshot value. | ||
// Older versions will rely on our polyfilled value. | ||
// It's important to check for the "__reactInternalSnapshot" value first though, | ||
// Since <= 15.x versions of React will pass a prevContext param to componentDidUpdate. | ||
var snapshot = this.__reactInternalSnapshot || maybeSnapshot; | ||
// 16.3+ will not execute our will-update method; | ||
// It will pass a snapshot value to did-update though. | ||
// Older versions will require our polyfilled will-update value. | ||
// We need to handle both cases, but can't just check for the presence of "maybeSnapshot", | ||
// Because for <= 15.x versions this might be a "prevContext" object. | ||
// We also can't just check "__reactInternalSnapshot", | ||
// Because get-snapshot might return a falsy value. | ||
// So check for the explicit __reactInternalSnapshotFlag flag to determine behavior. | ||
var snapshot = this.__reactInternalSnapshotFlag | ||
? this.__reactInternalSnapshot | ||
: maybeSnapshot; | ||
@@ -102,0 +109,0 @@ componentDidUpdate.call(this, prevProps, prevState, snapshot); |
@@ -39,2 +39,3 @@ (function (global, factory) { | ||
this.state = nextState; | ||
this.__reactInternalSnapshotFlag = true; | ||
this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate( | ||
@@ -99,7 +100,13 @@ prevProps, | ||
) { | ||
// 16.3+ will pass a snapshot value. | ||
// Older versions will rely on our polyfilled value. | ||
// It's important to check for the "__reactInternalSnapshot" value first though, | ||
// Since <= 15.x versions of React will pass a prevContext param to componentDidUpdate. | ||
var snapshot = this.__reactInternalSnapshot || maybeSnapshot; | ||
// 16.3+ will not execute our will-update method; | ||
// It will pass a snapshot value to did-update though. | ||
// Older versions will require our polyfilled will-update value. | ||
// We need to handle both cases, but can't just check for the presence of "maybeSnapshot", | ||
// Because for <= 15.x versions this might be a "prevContext" object. | ||
// We also can't just check "__reactInternalSnapshot", | ||
// Because get-snapshot might return a falsy value. | ||
// So check for the explicit __reactInternalSnapshotFlag flag to determine behavior. | ||
var snapshot = this.__reactInternalSnapshotFlag | ||
? this.__reactInternalSnapshot | ||
: maybeSnapshot; | ||
@@ -106,0 +113,0 @@ componentDidUpdate.call(this, prevProps, prevState, snapshot); |
@@ -1,1 +0,1 @@ | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):t.reactLifecyclesCompat=o()}(this,function(){"use strict";function t(){var t=this.constructor.getDerivedStateFromProps(this.props,this.state);null!==t&&void 0!==t&&this.setState(t)}function o(t){var o=this.constructor.getDerivedStateFromProps(t,this.state);null!==o&&void 0!==o&&this.setState(o)}function e(t,o){try{var e=this.props,n=this.state;this.props=t,this.state=o,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(e,n)}finally{this.props=e,this.state=n}}return t.__suppressDeprecationWarning=!0,o.__suppressDeprecationWarning=!0,e.__suppressDeprecationWarning=!0,function(n){if(!n.prototype||!n.prototype.isReactComponent)throw new Error("Can only polyfill class components");if("function"==typeof n.getDerivedStateFromProps){if("function"==typeof n.prototype.componentWillMount)throw new Error("Cannot polyfill getDerivedStateFromProps() for components that define componentWillMount()");if("function"==typeof n.prototype.componentWillReceiveProps)throw new Error("Cannot polyfill getDerivedStateFromProps() for components that define componentWillReceiveProps()");n.prototype.componentWillMount=t,n.prototype.componentWillReceiveProps=o}if("function"==typeof n.prototype.getSnapshotBeforeUpdate){if("function"==typeof n.prototype.componentWillUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that define componentWillUpdate()");if("function"!=typeof n.prototype.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");n.prototype.componentWillUpdate=e;var p=n.prototype.componentDidUpdate;n.prototype.componentDidUpdate=function(t,o,e){var n=this.__reactInternalSnapshot||e;p.call(this,t,o,n)}}return n}}); | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):t.reactLifecyclesCompat=o()}(this,function(){"use strict";function t(){var t=this.constructor.getDerivedStateFromProps(this.props,this.state);null!==t&&void 0!==t&&this.setState(t)}function o(t){var o=this.constructor.getDerivedStateFromProps(t,this.state);null!==o&&void 0!==o&&this.setState(o)}function e(t,o){try{var e=this.props,n=this.state;this.props=t,this.state=o,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(e,n)}finally{this.props=e,this.state=n}}return t.__suppressDeprecationWarning=!0,o.__suppressDeprecationWarning=!0,e.__suppressDeprecationWarning=!0,function(n){if(!n.prototype||!n.prototype.isReactComponent)throw new Error("Can only polyfill class components");if("function"==typeof n.getDerivedStateFromProps){if("function"==typeof n.prototype.componentWillMount)throw new Error("Cannot polyfill getDerivedStateFromProps() for components that define componentWillMount()");if("function"==typeof n.prototype.componentWillReceiveProps)throw new Error("Cannot polyfill getDerivedStateFromProps() for components that define componentWillReceiveProps()");n.prototype.componentWillMount=t,n.prototype.componentWillReceiveProps=o}if("function"==typeof n.prototype.getSnapshotBeforeUpdate){if("function"==typeof n.prototype.componentWillUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that define componentWillUpdate()");if("function"!=typeof n.prototype.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");n.prototype.componentWillUpdate=e;var p=n.prototype.componentDidUpdate;n.prototype.componentDidUpdate=function(t,o,e){var n=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:e;p.call(this,t,o,n)}}return n}}); |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
15164
211
0