ref(labels): use getDerivedStateFromProps to get display state
This commit is contained in:
parent
a045353e6e
commit
b24e7ec5f0
|
@ -32,6 +32,19 @@ type State = {
|
||||||
* @extends Component
|
* @extends Component
|
||||||
*/
|
*/
|
||||||
class Labels extends AbstractLabels<Props, State> {
|
class Labels extends AbstractLabels<Props, State> {
|
||||||
|
/**
|
||||||
|
* Updates the state for whether or not the filmstrip is transitioning to
|
||||||
|
* a displayed state.
|
||||||
|
*
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
static getDerivedStateFromProps(props, prevState) {
|
||||||
|
return {
|
||||||
|
filmstripBecomingVisible: !prevState.filmstripBecomingVisible
|
||||||
|
&& props._filmstripVisible
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new {@code Labels} instance.
|
* Initializes a new {@code Labels} instance.
|
||||||
*
|
*
|
||||||
|
@ -46,22 +59,6 @@ class Labels extends AbstractLabels<Props, State> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the state for whether or not the filmstrip is being toggled to
|
|
||||||
* display after having being hidden.
|
|
||||||
*
|
|
||||||
* @inheritdoc
|
|
||||||
* @param {Object} nextProps - The read-only props which this Component will
|
|
||||||
* receive.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
componentWillReceiveProps(nextProps) {
|
|
||||||
this.setState({
|
|
||||||
filmstripBecomingVisible: nextProps._filmstripVisible
|
|
||||||
&& !this.props._filmstripVisible
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements React's {@link Component#render()}.
|
* Implements React's {@link Component#render()}.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue