Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-sizeme fails to update size on resize event #157

Open
niwsa opened this issue Dec 10, 2018 · 6 comments
Open

react-sizeme fails to update size on resize event #157

niwsa opened this issue Dec 10, 2018 · 6 comments

Comments

@niwsa
Copy link

niwsa commented Dec 10, 2018

Sandbox up at https://codesandbox.io/s/r79nwzzv0n
Try resizing the sandbox preview window.
OS: Ubuntu 16.04,browser: Google chrome Version 70.0.3538.110 (Official Build) (64-bit)
Did I miss something the way I use sizeme?

@ctrlplusb
Copy link
Owner

Hey @niwsa - this is a very very strange bug. I have no idea why, but if you only put in the width then the resize events stop firing. If you add a "px" or any other content around the width then events do fire. I'm not sure if this issue is with React or one of my underlying dependencies. I did a large amount of debugging and couldn't see anything specific.

@ctrlplusb
Copy link
Owner

Here is your example working:
https://codesandbox.io/s/x7y9xz0l1o

FYI - codesandbox has a minimum width of 498px when I tested, so drag the panel wider than this when testing.

@niwsa
Copy link
Author

niwsa commented May 2, 2019

@ctrlplusb Thank you for digging into this 👏 Yes I see the wierd behaviour with the events firing.Will try finding some spare time to investigate more.

@Kingdutch
Copy link

In case it helps anyone, I dove into this a little bit and detailed my thoughts here: https://gist.github.com/Kingdutch/db2cf90050aa13271fc968d8e87ad259

Don't expect much cohesiveness, I was trying to debug a problem that someone else posted in a discord without having react-sizeme set-up myself. But maybe my thoughts can help someone fix this :D

@agarwal
Copy link

agarwal commented Apr 19, 2020

if you only put in the width then the resize events stop firing

A bit more precisely, it's whether or not you create additional arguments to the createElement that JSX desugars to. For example, <div>{size.width + "px"}</div>} still causes broken behavior.

@ctrlplusb
Copy link
Owner

Thanks all, some valuable insight which I plan to parse.

The internals are quite stale now as I wrote this ages ago, when I was still a newcomer to React. ☺️ I plan on doing a refresh soon hopefully and will take into account.

I'll also consider the debugability of the code.

Shall ping back here when things progress. 🧚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants