Skip to content

Commit

Permalink
Workaround for discrete passive effects change (#24369)
Browse files Browse the repository at this point in the history
This test is failing for the same reason as facebook/react#21173, so we'll borrow their fix, and follow along for updates.
  • Loading branch information
devknoll authored Apr 23, 2021
1 parent 079c629 commit 40216be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/integration/link-ref/pages/click-away-race-condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ const useClickAway = (ref, onClickAway) => {
el && !el.contains(event.target) && onClickAway(event)
}

document.addEventListener('click', handler)
let timeoutID = setTimeout(() => {
timeoutID = null
document.addEventListener('click', handler)
}, 0)

return () => {
if (timeoutID != null) {
clearTimeout(timeoutID)
}
document.removeEventListener('click', handler)
}
}, [onClickAway, ref])
Expand Down

0 comments on commit 40216be

Please sign in to comment.