File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -205,10 +205,11 @@ class OutPortal<C extends Component<any>> extends React.PureComponent<OutPortalP
205205 this . passPropsThroughPortal ( ) ;
206206 }
207207
208- componentDidUpdate ( ) {
208+ componentDidUpdate ( prevProps : OutPortalProps < C > ) {
209209 // We re-mount on update, just in case we were unmounted (e.g. by
210210 // a second OutPortal, which has now been removed)
211211 const node = this . props . node as AnyPortalNode < C > ;
212+ const prevNode = prevProps . node
212213
213214 // If we're switching portal nodes, we need to clean up the current one first.
214215 if ( this . currentPortalNode && node !== this . currentPortalNode ) {
@@ -220,11 +221,15 @@ class OutPortal<C extends Component<any>> extends React.PureComponent<OutPortalP
220221 const parent = placeholder . parentNode ! ;
221222 node . mount ( parent , placeholder ) ;
222223 this . passPropsThroughPortal ( ) ;
224+ if ( prevNode !== node ) {
225+ prevNode . setPortalProps ( { } as ComponentProps < C > ) ;
226+ }
223227 }
224228
225229 componentWillUnmount ( ) {
226230 const node = this . props . node as AnyPortalNode < C > ;
227231 node . unmount ( this . placeholderNode . current ! ) ;
232+ node . setPortalProps ( { } as ComponentProps < C > ) ;
228233 }
229234
230235 render ( ) {
You can’t perform that action at this time.
0 commit comments