Skip to content

Commit ad912ff

Browse files
Wrap update in function to prevent event from being passed as value (#1612)
Resolves #1556
1 parent 93c3d3e commit ad912ff

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/positioner/src/Positioner.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,13 @@ const Positioner = memo(function Positioner(props) {
152152
}
153153

154154
useEffect(() => {
155-
window.addEventListener('resize', update)
156-
window.addEventListener('scroll', update)
155+
const handleResizeOrScroll = () => update()
156+
window.addEventListener('resize', handleResizeOrScroll)
157+
window.addEventListener('scroll', handleResizeOrScroll)
157158

158159
return () => {
159-
window.removeEventListener('resize', update)
160-
window.removeEventListener('scroll', update)
160+
window.removeEventListener('resize', handleResizeOrScroll)
161+
window.removeEventListener('scroll', handleResizeOrScroll)
161162
}
162163
})
163164

0 commit comments

Comments
 (0)