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

Placeholder size not updating until a state change #226

Open
elizabethhyer opened this issue Sep 16, 2022 · 1 comment
Open

Placeholder size not updating until a state change #226

elizabethhyer opened this issue Sep 16, 2022 · 1 comment

Comments

@elizabethhyer
Copy link

I have an app that uses sizeme and CSS grid. When the app first renders (and on a hard or soft reload) the component that uses sizeme is squished, widthwise. It seems like the placeholder is taking its size estimate from grid.

The problem is that the size doesn't ever update until there's been a state change. Right now, as a work around, I'm updating state whenever the mouse enters the component, and this allows sizeme to start working (updating size when the screen is resized, using the entire width of the component instead of a single grid area).

I'm sorry I don't have a great way to illustrate this in a sandbox, but has anyone seen a component using sizeme get 'locked in' to a size until a state change?

adding noPlaceholder doesn't change this behavior.

@bradjones1
Copy link

I just ran into this as well, but without CSS grid.

I have a hybrid RN/RN-Web application where I control the maximum width of the root node (so as not to use the entire width of a very wide UA viewport.) The size passed to the child node render did not update.

As a workaround, I am using useWindowDimensions() and passing the width from it to the SizeMe element as an unused prop, but this is enough for React to trigger a re-render of the SizeMe element and its children because it sees it as a prop change.

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

2 participants