-
-
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
Style definitions vary within server/client side rendering #705
Comments
It would be nice if someone built a module that depended on autoprefixer or directly on caniuse-db that had a function like this:
|
Could be tricky too.. afaik, autoprefixer only takes CSS as a string, and no objects or JSON. |
I have the same problem. (client) 0;border-radius:2px;-webkit-user-select: any one can help? |
atm I don't have a solution on this. For me it was downgrading to |
I don't see how there can be a solution. Either you generate the same code or you don't. If you generate the same code, either you don't prefix and everything breaks, or you prefix in the same way. To prefix in the same way, you either do it browser-neutral or browser-specific. Browser-neutral means either pulling in a 2MB database for prefixing, or generating all prefixes for everything. Sucks on client side. Browser-specific means doing it the way v0.8 does client side, and browser sniffing on the server side. Sucks on server side. 👉 If you don't generate the same code, all react will do is adjust the styles on the html on first load. Is that really such a problem? |
As far as I know, React will not only add all missing components, but replace the entire DOM. But correct me if I'm wrong |
I ran into the same thing with fluxible.io. I'm currently looking at
with the checksum error
|
This creates a ton of jank on page-load for isomorphic apps. Replacing the entire DOM once the javascript arrives, especially on slower mobiles is just not a viable option. Browser sniffing on the server is a non-starter as soon as you want to set a cache header (Vary: user-agent is going to bust your cache hard). Front-end performance is more than just page weight. |
Ok, so that just leaves identifying the major culprits and moving them to On Wed, Aug 19, 2015, 06:02 Daniel Heath [email protected] wrote:
Wout. |
One of the main benefits of isomorphic apps is that the page looks right before the JS loads. That benefit is somewhat lost if you only prefix on the client-side; half the CSS rules will be missing. |
Any updates ? |
+1 |
I've been working on this. I'll have a PR soon.™ This is a fork of an inline prefixer library I found in a Radium issue discussion (they're having the same issue) The project initially is just for prefixing based on a user agent, which you can do. What's the catch? It doesn't work well with alternative css values. import Prefixer from 'inline-style-prefixer';
import ImmutabilityHelper from '../utils/immutability-helper';
// Combine all vendor prefixes
let prefixer = new Prefixer('*');
module.exports = {
all(styles) {
return prefixer.prefix(styles)
},
set(style, key, value) {
let mergedStyle = ImmutabilityHelper.merge.apply(this, prefixer.prefix({key: value}));
return mergedStyle
},
single(key, value) {
return prefixer.prefix({key: value})
},
}; Further performance gains can be made by rendering all prefixes on the server and on the first client load, |
@Cavitt So the solution you propose compute the missing prefix at the run-time. Still we have to consider #684, #1132
Well babel-plugin-react-autoprefix does, see https://github.com/UXtemple/babel-plugin-react-autoprefix/blob/master/__tests__/index-test.es6#L37 @shaurya947 @hai-cea Thougts? |
Hello guys, any updates in the issue? We have implemented material ui and when switched to universal app got the issue. It's quite important for react development, maybe authors can give us vision of their next steps in this? |
So this just came out: Seems like an interesting mix between defining styles in js and using The only sane way to solve the server-side rendering issue is by using On Mon, Oct 26, 2015, 1:51 PM Aleksey Taranets [email protected]
Wout. |
Excuse terseness! Sent from my iPhone
|
@oliviertassinari actually there shouldn't be any reason we can't use useragent when rendering on the server and client. The missing prefixes are computed server-side like autoprefixer would do, but they're also able to be computed client side. Honestly though switching to Radium after this is implemented on their end would be the best move imo. |
I've submitted a PR that might be a suitable solution for most #2007. |
Was that issue fixed? Have anyone verified it? I'm using material 0.15.3 and react 15.3.0 and getting: All is related to: |
I have a React app, that runs on the server and in the clients browser.
When I upgrade to
v0.8.0
, React gives me the "Expected html differs from the given markup" warning, because there are differences in the inline style definitions. For example:Server renders:
But the client (Chrome in this case) renders
While it is nice to not have to worry about vendor prefixes, the correct handling of them creates those differences. Does anyone have an idea on how to fix (or workaround) this? I dont want to send the client, perfectly good markup, and then let React rebuild half of it, because of that.
Maybe include all prefixes necessary? Might be tricky as well..
Or do I have to exclude all css that needs to be prefixed back into style sheets?
The text was updated successfully, but these errors were encountered: