Open aviaryan opened 5 years ago
Can you show me a minimal reproduction so I can take a look?
Thanks for the quick reply. I created a test sandbox to share here but the same doesn't seem to be happening in it. Looking into my original code, here is what is happening.
resize
handlers fire. The child has an absolute positioned element that takes some time to adjust to the new width because the width is based on a state value which is updated on resize. The absolute position element is initially taking 1200px width.withSizesHOC
doesn't update isMobile
prop since breakpoint is at 480px.resize
event isn't fired now or maybe it is throttled causing withSizes
to not update the isMobile
prop.If it is a bug, it could be related to #32
However, since I am not able to replicate it on the test code, you can close this issue. I am thinking of using a different approach for what I am doing anyway.
You can find the test code here. https://codesandbox.io/embed/react-sizes-issue-r706q
React Sizes won't update the props when a child component is also using the
resize
event.Example - A child component of the component that I am using
withSizes
on has aresize
handler defined.When the above is defined, react sizes fails to update the props passed to the parent component.
When I remove the
resize
handler from the child component and make no other changes,react-sizes
works as expected. That's why I think there could be a bug here.Let me know if you need any more details.