Alternative fix without setState in ComponentDidMount

This commit is contained in:
Sean King
2020-10-29 09:30:08 -06:00
parent 3a1bb8f19b
commit df85d707bb
2 changed files with 1 additions and 3 deletions

View File

@ -112,7 +112,6 @@ class Status extends ImmutablePureComponent {
// Track height changes we know about to compensate scrolling
componentDidMount() {
this.didShowCard = !this.props.muted && !this.props.hidden && this.props.status && this.props.status.get('card');
this.setState({ showMedia: defaultMediaVisibility(this.props.status, this.props.displayMedia) });
}
getSnapshotBeforeUpdate() {
@ -126,7 +125,7 @@ class Status extends ImmutablePureComponent {
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.status && nextProps.status.get('id') !== prevState.statusId) {
return {
showMedia: defaultMediaVisibility(nextProps.status),
showMedia: defaultMediaVisibility(nextProps.status, nextProps.displayMedia),
statusId: nextProps.status.get('id'),
};
} else {

View File

@ -146,7 +146,6 @@ class Status extends ImmutablePureComponent {
componentDidMount() {
this.props.dispatch(fetchStatus(this.props.params.statusId));
attachFullscreenListener(this.onFullScreenChange);
this.setState({ showMedia: defaultMediaVisibility(this.props.status, this.props.displayMedia) });
}
handleToggleMediaVisibility = () => {