Skip to content

Commit f644027

Browse files
Hotfix/portal memory leak (#26435)
* clean virtual parent reference * changelog * reuse setVirtual and remove cleanVirtualParent
1 parent 294d8a7 commit f644027

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "clean up parent reference to avoid memory leaks",
4+
"packageName": "@fluentui/react-portal",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/react-portal/src/components/Portal/usePortal.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export const usePortal_unstable = (props: PortalProps): PortalState => {
2626
if (state.virtualParentRootRef.current && state.mountNode) {
2727
setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
2828
}
29+
return () => {
30+
if (state.mountNode) {setVirtualParent(state.mountNode, undefined);}
31+
};
2932
}, [state.virtualParentRootRef, state.mountNode]);
3033

3134
return state;

0 commit comments

Comments
 (0)