ZeeCoder / use-resize-observer

A React hook that allows you to use a ResizeObserver to measure an element's size.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't pass sizes to parent components

corysimmons opened this issue · comments

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

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

hah, my bad. Thanks Viktor. :)