Skip to content

Commit

Permalink
Fix React warning while unmounting slots (#23365)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Jun 23, 2020
1 parent 4a4de28 commit 960dd92
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/components/src/slot-fill/slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SlotComponent extends Component {
constructor() {
super( ...arguments );

this.isUnmounted = false;
this.bindNode = this.bindNode.bind( this );
}

Expand All @@ -33,7 +34,7 @@ class SlotComponent extends Component {

componentWillUnmount() {
const { unregisterSlot } = this.props;

this.isUnmounted = true;
unregisterSlot( this.props.name, this );
}

Expand All @@ -50,6 +51,13 @@ class SlotComponent extends Component {
this.node = node;
}

forceUpdate() {
if ( this.isUnmounted ) {
return;
}
super.forceUpdate();
}

render() {
const { children, name, fillProps = {}, getFills } = this.props;

Expand Down

0 comments on commit 960dd92

Please sign in to comment.