kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Alternative fix without setState in ComponentDidMount
rodzic
3a1bb8f19b
commit
df85d707bb
|
@ -112,7 +112,6 @@ class Status extends ImmutablePureComponent {
|
||||||
// Track height changes we know about to compensate scrolling
|
// Track height changes we know about to compensate scrolling
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.didShowCard = !this.props.muted && !this.props.hidden && this.props.status && this.props.status.get('card');
|
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() {
|
getSnapshotBeforeUpdate() {
|
||||||
|
@ -126,7 +125,7 @@ class Status extends ImmutablePureComponent {
|
||||||
static getDerivedStateFromProps(nextProps, prevState) {
|
static getDerivedStateFromProps(nextProps, prevState) {
|
||||||
if (nextProps.status && nextProps.status.get('id') !== prevState.statusId) {
|
if (nextProps.status && nextProps.status.get('id') !== prevState.statusId) {
|
||||||
return {
|
return {
|
||||||
showMedia: defaultMediaVisibility(nextProps.status),
|
showMedia: defaultMediaVisibility(nextProps.status, nextProps.displayMedia),
|
||||||
statusId: nextProps.status.get('id'),
|
statusId: nextProps.status.get('id'),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -146,7 +146,6 @@ class Status extends ImmutablePureComponent {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.dispatch(fetchStatus(this.props.params.statusId));
|
this.props.dispatch(fetchStatus(this.props.params.statusId));
|
||||||
attachFullscreenListener(this.onFullScreenChange);
|
attachFullscreenListener(this.onFullScreenChange);
|
||||||
this.setState({ showMedia: defaultMediaVisibility(this.props.status, this.props.displayMedia) });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleToggleMediaVisibility = () => {
|
handleToggleMediaVisibility = () => {
|
||||||
|
|
Ładowanie…
Reference in New Issue