SSR and <Fade> : Prop `style` did not match
See original GitHub issueHello,
I want to surround a component with <Fade> only when on client side. So here is what my code look like :
import React from 'react';
import {Fade} from '@material-ui/core';
const isServer = function() {
return !(
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
);
};
class MyComponent extends React.Component {
render() {
const content = (
<div>Hello</div>
);
if (isServer()) {
return content;
}
return (
<Fade in={true} timeout={2500} mountOnEnter unmountOnExit>
{content}
</Fade>
);
}
}
export default MyComponent;
This code generate the following warning on the client-side console :
Warning: Prop
style
did not match. Server: “null” Client: “opacity:0;will-change:opacity”
How can I avoid this ?
Thank you
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
SSR and <Fade> : Prop `style` did not match · Issue #13471
Hello, I want to surround a component with only when on client side. So here is what my code look like : import...
Read more >Next.js, why? Warning: Prop `style` did not match. Server ...
As some people had the same issue as you do, you can try two things : Import Your component a different way, without...
Read more >Warning: Prop className did not match-Reactjs
The problem is the SSR rendering in Next.js, which produces the style fragment before the page is rendered. Using Material UI and Next.js...
Read more >Tag: Server-side Rendering - somewhat abstract
Console output showing warning that says "Prop 'src' did not match" along Hydration error in React 17.0. This is from React 17, though...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@remigarcia It’s a React issue, you can’t do that. I can share with you two helpers:
NoSrr https://material-ui.com/utils/no-ssr/
SrrOnly.js the opposite of NoSrr
If your issue is with the first animation, use
<Fade appear={false}>
.@remigarcia From my understanding, react-transition-group can be configured for your SSR use case. Just have to dig into the right properties combination. The Fade do support it.