From ca9391b6d1d00c6c03731dd6fcc43d5cc6f13dbe Mon Sep 17 00:00:00 2001 From: "John L. Armstrong IV" Date: Sat, 18 Sep 2021 05:15:55 -0400 Subject: [PATCH 1/2] fix: remove deprecated lifecycle methods for React strict mode compatibility. See https://github.com/cpunion/react-actioncable-provider/pull/39 --- lib/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6953192..fd894ab 100644 --- a/lib/index.js +++ b/lib/index.js @@ -11,7 +11,7 @@ var createReactClass = require("create-react-class") var { Provider, Consumer } = React.createContext() var ActionCableProvider = createReactClass({ - UNSAFE_componentWillMount: function () { + componentDidMount: function () { if (this.props.cable) { this.cable = this.props.cable } else { @@ -25,7 +25,7 @@ var ActionCableProvider = createReactClass({ } }, - UNSAFE_componentWillReceiveProps: function (nextProps) { + getDerivedStateFromProps: function (nextProps) { // Props not changed if ( this.props.cable === nextProps.cable && @@ -38,7 +38,7 @@ var ActionCableProvider = createReactClass({ this.componentWillUnmount() // create or assign cable - this.UNSAFE_componentWillMount() + this.componentDidMount() }, render: function () { From 838977490df8cf2cac8f6d771519d4d45593e759 Mon Sep 17 00:00:00 2001 From: "John L. Armstrong IV" Date: Sat, 18 Sep 2021 06:08:35 -0400 Subject: [PATCH 2/2] fix: switch to componentDidUpdate --- lib/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index fd894ab..4e4536b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -25,11 +25,11 @@ var ActionCableProvider = createReactClass({ } }, - getDerivedStateFromProps: function (nextProps) { + componentDidUpdate: function (prevProps) { // Props not changed if ( - this.props.cable === nextProps.cable && - this.props.url === nextProps.url + this.props.cable === prevProps.cable && + this.props.url === prevProps.url ) { return }