Skip to content

Commit

Permalink
fix(unmount): Flush useEffect cleanup functions syncronously
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jul 15, 2020
1 parent 240900c commit 6ef64ea
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/__tests__/render.js
Expand Up @@ -87,3 +87,17 @@ test('renders options.wrapper around node', () => {
</div>
`)
})

test('flushes useEffect cleanup functions sync on unmount()', () => {
const spy = jest.fn()
function Component() {
React.useEffect(() => spy, [])
return null
}
const {unmount} = render(<Component />)
expect(spy).toHaveBeenCalledTimes(0)

unmount()

expect(spy).toHaveBeenCalledTimes(1)
})

0 comments on commit 6ef64ea

Please sign in to comment.