-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Unable to use this in isomorphic apps #748
Comments
Currently I thought of 3 ways to fix this:
|
Vote up for 3 by @MrOrz ! |
vote up for 3 👍 |
The problem with 3, is that sometimes you need one css property to map to several different values. For example, prefixing
needs to give:
which can't be represented in a react style object. Maybe we could submit a PR to react, so that components can accept styles like:
|
I would like to chime in here. |
@pomerantsev Yeah I agree with you that the problem is not just for material-ui; the whole React community is still exploring how to achieve the holy grail of modular, inline CSS. The checksum warning is not a big deal in most cases. However, it does indicate that React is rewriting the whole DOM under the mount node ( https://github.com/facebook/react/blob/master/src/renderers/dom/client/ReactMount.js#L884 ). Personally I think it is more expensive than server-side prefixing, which involves just simple string catenation. As for which prefixes to add, maintaining an up-to-date prefix database indeed requires lots of hard work. But autoprefixer does that heavy lifting for us, and material-ui is already using autoprefixer. |
That react rewrite only happens once, right? Is that such a big deal? Isomorphic apps provide fast initial render speed and SEO, and the local rewrite is invisible to the user. Alternatively, the prefixer could adjust the checksums. Finally, server-side rendering could use auto-prefixer internally, probably it's not that hard to make sure client bundles do not include auto-prefixer. |
That's not the problem with shipping server rendered markup, the issue is you've generated the markup server side and react in the browser is unable to use any of it. So you've transferred a payload that provides no benefit. |
Can you give an example on how you are rendering your code server side? Are you sure inline css is the culprit? I use inline CSS in my geoshare app and do not receive checksum errors. The only time I ever received the checksum error was when I was not passing matching props/state to both the server and client. |
Related to #705 |
I am having same problem and thanks to this issue now I understand why this happens. However regardless of how to make autoprefixing work on server side, my question is why Thanks! |
A solution would be to create css just for the things that need prefixing, On Wed, Jul 1, 2015, 09:47 Xiao Zhang [email protected] wrote:
Wout. |
Not sure it was a good thing to remove all css for inline styles... It makes the DOM really hard to read, and it's impossible to override styles with our custom CSS. |
There is a theme manager you can use - its pretty easy
|
@x1a0 @tleunen As for me using inline styles or CSS is like a matter of taste. @callemall just took a stand. Some reasons for & against using inline styles are aggregated in this awesome css-tricks article: And here is the discussion about using inline styles in material-ui: #30 |
@callemall @MrOrz In our project, we are using https://github.com/twbs/bootstrap-sass with https://github.com/webpack/css-loader. This combination gives us a clean global CSS environment. For example, you can create a file called
Then in the generated CSS, you will have Bootstrap's button classes defined under your "local" class, something like:
In your React component you can just write:
In this way we can keep CSS of material-ui in CSS files while still easy to customize the theme. |
imo this is pretty complicated and too opinionated
|
@hai-cea Is there any new solution for this problem yet ? |
In case it helps, I got React isomorphic working with this https://github.com/react-materialize/react-materialize which is using materialize http://materializecss.com/ |
Any updates ? |
👍 |
I have a solution working, I'll submit a PR today. |
News? |
This is a duplicate of #705. |
Since
Modernizr
only inserts the relevant browser prefix on the client render, there's a mismatch with the unprefixed server side render. As alluded to in #591 , this causes the following warning in react:I don't see any easy fixes for this, and it's quite a biggie, which is saddening. Obviously getting this whole module to move away from inline styles is a no-go.
Pure speculation: maybe it's possible to patch the way react handles styles, so that when a component is supplied with
style={{'transition': 'all 1s'}}
, it's prefixed at the same time it's rendered to HTML, so it becomes:instead of simply
The text was updated successfully, but these errors were encountered: