ZeeCoder / use-resize-observer

A React hook that allows you to use a ResizeObserver to measure an element's size.
MIT License
644 stars 42 forks source link

Can't pass sizes to parent components #20

Closed corysimmons closed 4 years ago

corysimmons commented 4 years ago

This would be really handy with things like styled-components. I peeked at the source and it looks like it's using useEffect under the hood, so I'm not sure why it isn't able to watch/update appropriately.

https://codesandbox.io/s/useresizeobserver-react-hook-cstgc

ZeeCoder commented 4 years ago

You have a missing px in your CSS calc, just change it to: calc(300px + ${props.h}px)

corysimmons commented 4 years ago

hah, my bad. Thanks Viktor. :)