-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
[utils] Server side rendering #6068
Comments
That's a known limitation of this Higher-order Component. |
Oh, are you saying you want to change the component to accept a |
@oliviertassinari Yes exactly. I want to be able to set width manually depending on |
In that case, we would accept a PR to override the inner state 👍 . |
I just ran into this issue (I think). When attempting to use
is there any recommended work-around to deal with this, while this issue is open ? |
The recommended workaround would be, do not use that util. It really depends on the situation. The best situation is when you can use CSS media queries. This issue is kept open as looking for work-around. So your question have all his place here. So far, we have:
|
ok, thanks. Another option might be responsive-redux, which has option to provide default values for server side rendering. |
Some side though on this new property. People using it should have some mechanism so that the property stay the same between the server side rendering and the client side rendering. Closes #6068
@oliviertassinari A few month have passed, what would be the workaround of choice nowadays ? |
@sebastienfi In my project I use express-device and set |
@oliviertassinari Hi, any chance on getting the initialWidth from the theme?
It will help to not being passing the initialWidth to every component as props, or do something else ugly to handle this configuration globally. Any drawbacks on this approach? |
@kleyson Yes, we could pull the value out of the theme. I'm not sure about |
@oliviertassinari Thanks for the quick answer!! Can you point me a direction? I can do the PR with the code/test/docs if that can help. |
@kleyson What do you think of using |
@oliviertassinari any plans/news about this feature? We have components we use in many places and it's very painful to always set |
@n-sviridenko It's already live. |
@oliviertassinari weird, since which version? |
This comment has been minimized.
This comment has been minimized.
Hi, my comment was marked resolved. So, is this comment the answer to my question? #6068 (comment) |
Hi, no better solution yet ? |
Thanks for fast reply! |
@sm-hashemi You can use the CSS implementation of the Hidden component: https://material-ui.com/layout/hidden/#css. |
@oliviertassinari Thanks! I have
|
|
I moved from using |
@junibrosas Did you try this API? import useMediaQuery from '@material-ui/core/useMediaQuery';
function MyComponent() {
const matches = useMediaQuery(theme => theme.breakpoints.up('sm'));
return <span>{`theme.breakpoints.up('sm') matches: ${matches}`}</span>;
} https://material-ui.com/components/use-media-query/#using-material-uis-breakpoint-helpers |
@oliviertassinari yes, and I am using MUI 3.9.3 so this is how I import it:
|
|
Problem description
Server side rendering breaks when using
withWidth
util as we have in/material-ui/utils/withWidth.js
:Need to have ability to pass width when rendering on server or set width depending on
userAgent
.Versions
The text was updated successfully, but these errors were encountered: