diff --git a/react/index.native.js b/react/index.native.js index b3f0bf10a..cb89314bf 100644 --- a/react/index.native.js +++ b/react/index.native.js @@ -103,15 +103,25 @@ class Root extends Component { } /** - * Implements React's {@link Component#componentWillReceiveProps()}. + * Implements React's {@link Component#componentDidUpdate()}. * * New props can be set from the native side by setting the appProperties * property (on iOS) or calling setAppProperties (on Android). * * @inheritdoc */ - componentWillReceiveProps({ url }) { - equals(this.props.url, url) || this.setState({ url: url || null }); + componentDidUpdate(prevProps, prevState) { + // Ignore the special state update triggered on {@code Root} + // instantiation where an undefined url prop is set to a default. + if (typeof prevState.url === 'undefined' + && typeof this.state.url !== 'undefined') { + return; + } + + if (!equals(prevProps.url, this.props.url)) { + // eslint-disable-next-line react/no-did-update-set-state + this.setState({ url: this.props.url || null }); + } } /**