Skip to content

Commit

Permalink
fix(useOverflowContainer): Removes double overflowManager creation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ling1726 authored Sep 5, 2024
1 parent 3c58526 commit 47f0893
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix(useOverflowContainer): Removes double overflowManager creation",
"packageName": "@fluentui/react-overflow",
"email": "lingfangao@hotmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const useOverflowContainer = <TElement extends HTMLElement>(
update: OnUpdateOverflow,
options: Omit<ObserveOptions, 'onUpdateOverflow'>,
): UseOverflowContainerReturn<TElement> => {
'use no memo';

const {
overflowAxis = 'horizontal',
overflowDirection = 'end',
Expand Down Expand Up @@ -74,7 +76,9 @@ export const useOverflowContainer = <TElement extends HTMLElement>(
const newOverflowManager = createOverflowManager();
newOverflowManager.observe(containerRef.current, overflowOptions);
setOverflowManager(newOverflowManager);
}, [overflowOptions, firstMount]);
// We don't want to re-create the overflow manager when the first mount flag changes from true to false
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [overflowOptions]);

/* Clean up overflow manager on unmount */
React.useEffect(
Expand Down

0 comments on commit 47f0893

Please sign in to comment.