Skip to content
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

Warning: Prop id did not match. #26

Open
shlaikov opened this issue May 23, 2019 · 14 comments · May be fixed by #36
Open

Warning: Prop id did not match. #26

shlaikov opened this issue May 23, 2019 · 14 comments · May be fixed by #36

Comments

@shlaikov
Copy link

shlaikov commented May 23, 2019

Hello, I'm rendering React 16 on client and server(SSR) with new function React.hydrate(). And console throw Warning message:
Warning: Prop id did not match. Server: "starGrad239537257264089" Client: "starGrad357747279155326"

This is the only problem with this component. Thank's a lot!

@zenorocha
Copy link

I'm having the same problem using Next.js

@robin-thomas
Copy link

robin-thomas commented Jul 5, 2019

Me too.
Probably coz of the fillId: https:/ekeric13/react-star-ratings/blob/master/src/star-ratings.js#L9

@castasamu
Copy link

Me too.
image

fillId = `starGrad${Math.random().toFixed(15).slice(2)}`;

@chungskie
Copy link

These random numbers are also no bueno for creating snapshots... 😢

@christophby
Copy link

I provided a PR #36 to solve this problem.
You can set an Id to the rating component which makes sure that the fill-Id internally doesn’t change between server & client.

@ForeshadowRU
Copy link

Any updates on this? :(

@BodyaNK
Copy link

BodyaNK commented Sep 23, 2020

If you're using Next js with server side rendering, you need to import StarRatings from "react-star-ratings" dynamically with no ssr. For example:

import dynamic from "next/dynamic";
const StarRatings = dynamic(() => import("react-star-ratings"), {
  ssr: false,
});

For me it's work. Hope this will help.

@maxgfr
Copy link

maxgfr commented Nov 5, 2020

Problem resolved with @BodyaNK solution. Thanks

@irving-caamal
Copy link

irving-caamal commented Nov 20, 2020

If you're using Next js with server side rendering, you need to import StarRatings from "react-star-ratings" dynamically with no ssr. For example:

import dynamic from "next/dynamic";
const StarRatings = dynamic(() => import("react-star-ratings"), {
  ssr: false,
});

For me it's work. Hope this will help.

Just to complement this resolved Issue, I've had to import dynamic child's components when the parent component is dynamic too

@yahya-aghdam
Copy link

I have this issue and I must use SSR. Do you have any solution?

@renenielsendk
Copy link

If you're using Next js with server side rendering, you need to import StarRatings from "react-star-ratings" dynamically with no ssr. For example:

import dynamic from "next/dynamic";
const StarRatings = dynamic(() => import("react-star-ratings"), {
  ssr: false,
});

For me it's work. Hope this will help.

@BodyaNK How did u get this working? I did it, and the error dissapeared. But now i can't access the properties from the component.
Screenshot 2021-10-01 at 12 42 40

@jeekooo
Copy link

jeekooo commented Dec 14, 2021

For me doesn't work
import dynamic from "next/dynamic";
const Tab = dynamic(() => import("react-bootstrap"), {
ssr: false,
});
2021-12-14_123602

@eltel
Copy link

eltel commented May 7, 2023

For me doesn't work import dynamic from "next/dynamic"; const Tab = dynamic(() => import("react-bootstrap"), { ssr: false, }); 2021-12-14_123602

Me neither, immensely frustrating - has anybody found a workaround?

Thanks in advance

@sakamossan
Copy link

I am using [email protected] and encountering the same error.

I tried the pull request implemented by @christophby, it worked as expected in my simple use case.

Replacing with his implementation

$ npm install 'git+https:/christophby/react-star-ratings.git#e58364b7b9008e59f22844c26f96cf5d02e61851'

Adding id: string to the props

Since id is not yet defined in @types/react-star-ratings, you'll need to use @ts-expect-error.

<StarRatings
+   // @ts-expect-error
+   id={name.toString()}
    rating={starRate}
    starSpacing="0.1rem"
    starRatedColor="#f5c518"
    starDimension="2rem"
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.