-
Notifications
You must be signed in to change notification settings - Fork 46
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
Get the raw width and height of container #14
Comments
Currently the width and height is not provided. But I could update the API this weekend.
|
@tonyxiao Could I ask you what's your use case for accessing width and height? |
@d6u I need to dynamically compute the number of children components to render based on parent width. Essentially the "breakpoints" are dynamic and doesn't lend itself well to a set of predefined queries. |
@tonyxiao I see, thanks |
@tonyxiao After some thinking, I'm hesitated to pass down width and height to wrapped component due to performance concerns. However, I see why you need this feature. So here I want to ask a few things before implementation. Performance concernsIf you are using higher order component API, passing down width and height to child component will make child to rerender because of new props. When component is resizing the width and height changes very frequent. Since underneath it's using WorkaroundFortunately, when designing the API, I left an option that uses mixin. I know mixin is "lame" ( Here is how it will work for you. If you use How does that sound to you, do you think mixin API is cool enough 😄 ? |
Hey @d6u , thanks so much for the extensive consideration. I think that's more than enough. Isolated uses of Mixin should be ok anyways. For what it's worth I also considered this lib - https://github.com/ctrlplusb/react-sizeme. Do you have any thoughts? |
@tonyxiao react-sizeme looks really nice! I think they will perform better than react-container-query due to there resize detection strategy. One caveat about scroll strategy, it will place a So depends on your requirements, that might not be a desire thing for you. However, the benefit is that it should perform much better. |
Is there a way to access the raw width and height, not just whether they match specific queries?
The text was updated successfully, but these errors were encountered: