Skip to content

Commit

Permalink
In React >=16.3, use unsafe lifecycle methods to avoid warnings, even…
Browse files Browse the repository at this point in the history
… in development (#1410)
  • Loading branch information
samkline authored and timdorr committed Oct 1, 2019
1 parent 4144715 commit 2978315
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/connectAdvanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ export default function connectAdvanced(

if (prefixUnsafeLifecycleMethods) {
// Use UNSAFE_ event name where supported
Connect.UNSAFE_componentWillReceiveProps = Connect.componentWillReceiveProps
delete Connect.componentWillReceiveProps
Connect.prototype.UNSAFE_componentWillReceiveProps = Connect.prototype.componentWillReceiveProps
delete Connect.prototype.componentWillReceiveProps
}

/* eslint-enable react/no-deprecated */
Expand All @@ -280,7 +280,9 @@ export default function connectAdvanced(
Connect.propTypes = contextTypes

if (process.env.NODE_ENV !== 'production') {
Connect.prototype.componentWillUpdate = function componentWillUpdate() {
// Use UNSAFE_ event name where supported
const eventName = prefixUnsafeLifecycleMethods ? 'UNSAFE_componentWillUpdate' : 'componentWillUpdate';
Connect.prototype[eventName] = function componentWillUpdate() {
// We are hot reloading!
if (this.version !== version) {
this.version = version
Expand Down

0 comments on commit 2978315

Please sign in to comment.