react-star-ratings icon indicating copy to clipboard operation
react-star-ratings copied to clipboard

Warning: Prop `id` did not match.

Open shlaikov opened this issue 6 years ago • 14 comments

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!

shlaikov avatar May 23 '19 10:05 shlaikov

I'm having the same problem using Next.js

zenorocha avatar Jun 29 '19 21:06 zenorocha

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

robin-thomas avatar Jul 05 '19 02:07 robin-thomas

Me too. image

https://github.com/ekeric13/react-star-ratings/blob/07add0e61bf77fb94a9613587e31bffa9f46364e/src/star-ratings.js#L9

castasamu avatar Dec 15 '19 19:12 castasamu

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

chungskie avatar Feb 06 '20 22:02 chungskie

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.

christophby avatar May 01 '20 22:05 christophby

Any updates on this? :(

ForeshadowRU avatar Sep 11 '20 06:09 ForeshadowRU

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 avatar Sep 23 '20 15:09 BodyaNK

Problem resolved with @BodyaNK solution. Thanks

maxgfr avatar Nov 05 '20 20:11 maxgfr

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

irving-caamal avatar Nov 20 '20 17:11 irving-caamal

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

yahya-aghdam avatar Aug 20 '21 10:08 yahya-aghdam

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

renenielsendk avatar Oct 01 '21 10:10 renenielsendk

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

jeekooo avatar Dec 14 '21 10:12 jeekooo

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

eltel avatar May 07 '23 22:05 eltel