Open AdamKasela opened 1 year ago
Very straightforward: your img
element enters and leaves the DOM and the hook doesn't use ref.current
as a dependency, just ref
. You need to set the ref via useState
instead of useRef
in this case, as shown in the example here: https://codesandbox.io/s/react-hookresize-observer-example-ft88x
I'm not sure why but Resize observer is not triggering at all. I tried using useSize hook implemented from this lib but this also is not working. Can you pls help me somebody ? What can cause this issue ? When I use target.current in dependency array of useLayoutEffect the initial width and height get set but consecutive resizing doesn't trigger anything.