Skip to content

Commit 40216be

Browse files
authoredApr 23, 2021
Workaround for discrete passive effects change (#24369)
This test is failing for the same reason as facebook/react#21173, so we'll borrow their fix, and follow along for updates.
1 parent 079c629 commit 40216be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎test/integration/link-ref/pages/click-away-race-condition.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ const useClickAway = (ref, onClickAway) => {
1313
el && !el.contains(event.target) && onClickAway(event)
1414
}
1515

16-
document.addEventListener('click', handler)
16+
let timeoutID = setTimeout(() => {
17+
timeoutID = null
18+
document.addEventListener('click', handler)
19+
}, 0)
1720

1821
return () => {
22+
if (timeoutID != null) {
23+
clearTimeout(timeoutID)
24+
}
1925
document.removeEventListener('click', handler)
2026
}
2127
}, [onClickAway, ref])

0 commit comments

Comments
 (0)
Please sign in to comment.