Skip to content

Commit

Permalink
Workaround for discrete passive effects change
Browse files Browse the repository at this point in the history
  • Loading branch information
devknoll committed Apr 23, 2021
1 parent 079c629 commit 9005133
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 9005133

Please sign in to comment.