Warning: Prop `className` did not match. when using styled compoenents with semantic-ui-react
Clash Royale CLAN TAG#URR8PPP
Warning: Prop `className` did not match. when using styled compoenents with semantic-ui-react
I use this code to margin my Button from top:
const makeTopMargin = (elem) =>
return styled(elem)`
&&
margin-top: 1em !important;
`;
const MarginButton = makeTopMargin(Button);
and whenever i use MarginButton
node, I get this error: Warning: Prop
classNamedid not match. Server: "ui icon left labeled button sc-bwzfXH MjXOI" Client: "ui icon left labeled button sc-bdVaJa fKCkqX"
MarginButton
Warning: Prop
did not match. Server: "ui icon left labeled button sc-bwzfXH MjXOI" Client: "ui icon left labeled button sc-bdVaJa fKCkqX"
You can see this produced here.
What should I do?
Sorry, that ip is actually a vps but it is not running right now for a reason. I will try to reproduce it now.
– Talha Talip Açıkgöz
Aug 11 at 14:19
@brianespinosa Please see codesandbox.io/s/xvmq9jjzzq
– Talha Talip Açıkgöz
Aug 11 at 14:26
I am looking at your console and there is no proptype warning for className.
– brianespinosa
Aug 13 at 18:32
I think it happens only in development environment. I can't reproduce it online.
– Talha Talip Açıkgöz
Aug 13 at 22:05
1 Answer
1
PropType errors are runtime errors that will let you know that the data expected being passed to a prop is not what is expected. It looks like the className prop that is being set on your component is not the same when the component is rendered on the server and when it is then rendered in the client's DOM.
Since it looks like you are using server side rendering, you need to make sure that your class names are deterministic. That error is showing you the class that is being created by your styled-components
library on the server and how it is different from the DOM. For libraries that do not normally have deterministic class names, you need to look at advanced configurations. Take a look at the styled-components documentation regarding specificity as it pertains to SSR.
styled-components
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
The link you shared is to port :3000 on an IP address. Unless you have made that IP address available to public traffic and have a currently running web server there, nobody will be able to access what you are running. Try creating a minimal example of your problem using a tool like codesandbox instead. codesandbox.io
– brianespinosa
Aug 10 at 19:01