Skip to content

Commit 6ef64ea

Browse files
committed
fix(unmount): Flush useEffect cleanup functions syncronously
1 parent 240900c commit 6ef64ea

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/__tests__/render.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,17 @@ test('renders options.wrapper around node', () => {
8787
</div>
8888
`)
8989
})
90+
91+
test('flushes useEffect cleanup functions sync on unmount()', () => {
92+
const spy = jest.fn()
93+
function Component() {
94+
React.useEffect(() => spy, [])
95+
return null
96+
}
97+
const {unmount} = render(<Component />)
98+
expect(spy).toHaveBeenCalledTimes(0)
99+
100+
unmount()
101+
102+
expect(spy).toHaveBeenCalledTimes(1)
103+
})

0 commit comments

Comments
 (0)