-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
v3 prop className did not match warning in Next.js #3590
Comments
Same issue outside of Next.js, but when SSR'd. Using |
Any news on this one? Could it be because of emotion? |
Using Next.js and |
Warning: Prop |
same problem here as well, any idea? 🤔 |
Same here |
I also have this issue. It seems that on the client the components have a different label configuration, because on the backend there is no |
Okay, I found out what is the problem! In Turns out that next.js selected different module types for different environments. It loaded For now the quick fix I found in this thread is to change the example: // next.config.js
module.exports = {
webpack: config => {
config.resolve.mainFields = ["main", "browser", "module"];
return config;
},
}; The downside is that it can break other packages that must prioritize |
Looks like disabling SSR for a particular component works. |
thanks for the insight into the problem @maciejmatu, @mitchellhamilton any ideas on how to fix this issue for our next js users? |
Fixed this with an update to some regex in emotion. An example of it working by reinstalling react-select so the new version of emotion is used: https://codesandbox.io/s/hello-world-jtyix |
Still getting this error in 3.1.0 |
I'm also experiencing the same error now with |
Using |
Setting the It would be nice for this library to provide a
|
Thanks for the feedback all, we'll look into this. |
Hey @bladey, just wondering if you've had a chance to look into this by any chance? |
I can reproduce this hydration mismatch only on Safari browsers (both macOS and iOS) which is rather strange. Trace:
|
EDIT: 🎉 I've archived the fork now that we've got some momentum in this repo and Jed is involved again. Sorry for the disturbance! |
👀 |
I am seeing this issue in react-select v4.1 with React SSR, but it is only affecting Safari. Does anyone have any insights on this?
|
Have you tried setting both |
See emotion-js/emotion#2255 for the latest on this. Since it's been confirmed that this is not a production-impacting issue (it's an erroneous console error for Safari in development only) I'm taking this off the 5.1 milestone. #4088 is more important and is where I'll focus my efforts. |
It's not really a fix, but you can wrap with a |
@shehi I think you are experiencing a different problem. Try setting an instanceId prop. |
Having this same issue with Remix, React-Select v5.2.2 on Google Chrome, so it is definitely not Safari. I have set inputId and instanceId.
is what the error message switches to once I add instanceId. |
But what happen if I want to have different classes using SSR? I mean, I'm adding classes using Media Queries with react-responsive package but I don't see a good alternative to know that info from server side (I'm using RemixJS) 🤔 |
I was hoping that setting prop
|
Sadly I am having this issue as well and since there doesn't seem to be a viable fix for it yet, i will go with the soultions for now. Will have to come back to this later. |
I get this warning on the latest version of Chrome on MacOS at react 18.2 |
Same issue here with Remix. |
I think its the best resolution for now
|
Fix in Remix.js import { useHydrated } from 'remix-utils';
const isHydrated = useHydrated();
isHydrated ? <Select /> : null; Fix in Next.js and React.js import { useEffect, useState } from "react";
export const useMounted = (): { hasMounted: boolean } => {
const [hasMounted, setHasMounted] = useState(false);
useEffect(() => {
setHasMounted(true);
}, []);
return { hasMounted };
};
const { hasMounted } = useMounted();
hasMounted ? <Select /> : null; |
@EvgeniyBudaev the thing is, this causes a layout shift. Is it not possible to server side render react-select? |
@phifa Layout shift due to nulls. This is just an example. Instead of nulls, there can be an element with the same dimensions as select. I didn't make the example complicated. The main idea in solving the problem of server and client hydration. |
@EvgeniyBudaev Yeah i know, my question is, can the component simply not render on the server? |
hey all, is there any movement on this issue ? I don't see any truly viable solution here - we have tons of ReactSelects across our application - is the only solution to wrap all of them in a conditional ? Not only is this tedious and poor DX, it means the initial server code will be missing all of the inputs and then they'll all suddenly pop in. |
It happens the same to me using Remix. It only happens in development though, I'm pretty sure the main reason is because in development emotion suffixes the generated className with the displayName of the component, and for some reason the on the client the display name of react-select components change from
|
Any updates on this thread? react-select v5.7.3 react v18.2.0 |
I am also having the same issue. |
It keeps saying it's closed on this thread but the issue continues.. it has been three years now.. |
Same issue on Astro. |
Have you resolved this issue? |
Getting similar error when using isSearchable={false} hydration-error-info.js:63 Warning: Prop `className` did not match. Server: "css-1czm0f-dummyInput-DummyInput" Client: "css-mohuvp-dummyInput-DummyInput" <ReactSelect
...
isSearchable={false} |
Hi. I am seeing a warning since upgrading to version 3 with the latest versions of Next.js and React:
Warning: Prop className did not match. Server: "css-1g6gooi" Client: "css-w8afj7-Input"
See this sandbox for my reproduction:
https://codesandbox.io/s/helloworld-g1mb7
The text was updated successfully, but these errors were encountered: