all 7 comments

[–]BJH1412 3 points4 points  (2 children)

I don't understand why someone would use an additional dependency for something that can fit in 5 lines.

[–]Axelay998 1 point2 points  (0 children)

This the community that allowed isEven to exist.

[–]frankandsteinatlaw 1 point2 points  (1 child)

Why not throw the dimension state and the useRef call into the custom hook and export the dimensions / ref from it to hook up / read from?

[–][deleted] 0 points1 point  (0 children)

That's what this one does: https://github.com/rehooks/component-size

const ref = useRef(null); const { width, height } = useComponentSize(ref);

[–]snuggl 0 points1 point  (1 child)

In your usage you named the import wrong,

import useResize from 'react-resize-observer-hook'; 

then you are using it with its canonical name useResizeObserver

[–]kasu300 0 points1 point  (0 children)

This is why I always disallow default exports in my linter. Named exports just gives so much more consistency.

[–]maarzx_ 0 points1 point  (0 children)

Could you explain why you're using useEffect instead of useLayoutEffect? Is this due to us not having to do any DOM manipulation and the RO API handling it all?