DEV Community

Md Wahiduzzaman Emon
Md Wahiduzzaman Emon

Posted on

1

Answer: React 18: Hydration failed because the initial UI does not match what was rendered on the server

Just go main parent component and set the state:

const [isSSR,setIsSSR]=React.useState(false);
React.useEffect(()=>{
  setIsSSR(true);
})
return (
  isSSR && (
    <>
       //your component here
    </>
  )
)
</p>
Enter fullscreen mode Exit fullscreen mode





https://stackoverflow.com/a/74418607/16836455

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay