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
205
205
this . passPropsThroughPortal ( ) ;
206
206
}
207
207
208
- componentDidUpdate ( ) {
208
+ componentDidUpdate ( prevProps : OutPortalProps < C > ) {
209
209
// We re-mount on update, just in case we were unmounted (e.g. by
210
210
// a second OutPortal, which has now been removed)
211
211
const node = this . props . node as AnyPortalNode < C > ;
212
+ const prevNode = prevProps . node
212
213
213
214
// If we're switching portal nodes, we need to clean up the current one first.
214
215
if ( this . currentPortalNode && node !== this . currentPortalNode ) {
@@ -220,11 +221,15 @@ class OutPortal<C extends Component<any>> extends React.PureComponent<OutPortalP
220
221
const parent = placeholder . parentNode ! ;
221
222
node . mount ( parent , placeholder ) ;
222
223
this . passPropsThroughPortal ( ) ;
224
+ if ( prevNode !== node ) {
225
+ prevNode . setPortalProps ( { } as ComponentProps < C > ) ;
226
+ }
223
227
}
224
228
225
229
componentWillUnmount ( ) {
226
230
const node = this . props . node as AnyPortalNode < C > ;
227
231
node . unmount ( this . placeholderNode . current ! ) ;
232
+ node . setPortalProps ( { } as ComponentProps < C > ) ;
228
233
}
229
234
230
235
render ( ) {
You can’t perform that action at this time.
0 commit comments