maslianok / react-resize-detector

A Cross-Browser, Event-based, Element Resize Detection for React
http://maslianok.github.io/react-resize-detector/
MIT License
1.25k stars 91 forks source link

Fix ref `.current` set by using a proxy #249

Closed hugo-vrijswijk closed 9 months ago

hugo-vrijswijk commented 9 months ago

Since 9.0.0, when .current is set, this does not trigger a rerender. This is because the setRefElement function is only called when the ref set is called as a function. Certain libraries will set .current directly instead of calling the ref function, which React normally handles with a Ref, but the ref-like function in this hook introduced in 9.0.0 does not handle this case.

This PR fixes that by using a proxy to properly call setRefElement when .current is set.

snelsi commented 9 months ago

Published in v10.0.0-beta.1 and v9.1.2-beta.0

maslianok commented 9 months ago

Nice! 🔥