Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix(unmount): Flush useEffect cleanup functions syncronously
  • Loading branch information
eps1lon committed Jul 15, 2020
commit 6ef64ea4a070e83430e1a9ae7d76b8208bf55890
14 changes: 14 additions & 0 deletions src/__tests__/render.js
Original file line number Diff line number Diff line change
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)
})