react-sizeme icon indicating copy to clipboard operation
react-sizeme copied to clipboard

Explicitly in doc that Size children must be an HTML element

Open keul opened this issue 7 years ago • 1 comments

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.

keul avatar Sep 07 '18 15:09 keul

I experienced a similar issue. I was using <React.Fragment> as a direct child of <SizeMe> which caused an infinite loop in my application.

kaitmore avatar Oct 11 '18 20:10 kaitmore