react-sizeme
react-sizeme copied to clipboard
Explicitly in doc that Size children must be an HTML element
After a refactoring I found that react-sizeme was not working properly anymore; my size.width was 0.
This was my original call (I don't think the HOC version is important): sizeMe()(App)
The issue in the end was the composition of my App component: before the code change the main element was a div, while after that div is wrapped inside the the style-components's StyleSheetManager and a Fragment.
The fix was easy:
return (
<StyleSheetManager target={element}>
<Fragment>
<OtherStuff />
<SizeMe>
{({ size }) => (
<div>...
If I'm right, my suggestion is to improve the documentation by explicitly report this behavior.
I experienced a similar issue. I was using <React.Fragment> as a direct child of <SizeMe> which caused an infinite loop in my application.