Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: sync internal value of canRender with presence",
"packageName": "@fluentui/react-motion-preview",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ describe('useMotion', () => {
});

describe('when motion is received', () => {
it('should sync presence value with canRender', () => {
const { result, rerender } = renderHookWithRef(false);

expect(result.current.canRender).toBe(false);
rerender(true);

expect(result.current.canRender).toBe(true);
});

it('should return default values when presence is false', () => {
const defaultState = getDefaultMotionState();
const { result } = renderHookWithRef(getDefaultMotionState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ function useMotionPresence<Element extends HTMLElement>(
ref,
type,
active,
canRender: type !== 'unmounted',
canRender: presence || type !== 'unmounted',
}),
// No need to add ref to the deps array as it is stable
// eslint-disable-next-line react-hooks/exhaustive-deps
[active, type],
[active, type, presence],
);
}

Expand Down