ref(app): set url prop to state in componentDidUpdate
This is done to kill off the last deprecated lifecycle usage. There is special logic within index.native to get a default meeting url by asynchronously fetching it, if a url is not passed initially. The url is then put onto state and overridable on subsequent prop updates.
This commit is contained in:
parent
5c0ae10ccb
commit
29809ab024
|
@ -103,15 +103,25 @@ class Root extends Component<Props, State> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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 });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue