|
@@ -59,18 +59,19 @@ class LobbySection extends PureComponent<Props, State> {
|
59
|
59
|
}
|
60
|
60
|
|
61
|
61
|
/**
|
62
|
|
- * Implements {@code PureComponent#componentDidUpdate}.
|
|
62
|
+ * Implements React's {@link Component#getDerivedStateFromProps()}.
|
63
|
63
|
*
|
64
|
64
|
* @inheritdoc
|
65
|
65
|
*/
|
66
|
|
- componentDidUpdate(prevProps, prevState) {
|
67
|
|
- if (this.props._lobbyEnabled !== prevProps._lobbyEnabled
|
68
|
|
- && this.state.lobbyEnabled !== prevState.lobbyEnabled) {
|
69
|
|
- // eslint-disable-next-line react/no-did-update-set-state
|
70
|
|
- this.setState({
|
71
|
|
- lobbyEnabled: this.props._lobbyEnabled
|
72
|
|
- });
|
|
66
|
+ static getDerivedStateFromProps(props: Props, state: Object) {
|
|
67
|
+ if (props._lobbyEnabled !== state.lobbyEnabled) {
|
|
68
|
+
|
|
69
|
+ return {
|
|
70
|
+ lobbyEnabled: props._lobbyEnabled
|
|
71
|
+ };
|
73
|
72
|
}
|
|
73
|
+
|
|
74
|
+ return null;
|
74
|
75
|
}
|
75
|
76
|
|
76
|
77
|
/**
|