jonluca / vite-typescript-ssr-react

🚀 A Vite Typescript SSR React boilerplate!
https://blog.jonlu.ca/posts/vite
342 stars 48 forks source link

Encountered “Minified React error” in the production environment #12

Closed Zasvieeel closed 2 years ago

Zasvieeel commented 2 years ago

Hello. I've hosting this app on vercel and got unexpected error in console

Are this refers to vite configuration or not?

image

Please help..

jonluca commented 2 years ago

That error is https://reactjs.org/docs/error-decoder.html/?invariant=423&args%5B%5D=ni

There was an error hydrating the page - it means that the html that was shipped down the page was not SSRd.

This commit should fix it https://github.com/jonluca/vite-typescript-ssr-react/commit/63c142ec9608155e61c2729944198c07fe63ee17

But the relevant change is in entry-client.tsx

if (import.meta.hot || !container?.innerText) {
  const root = createRoot(container!);
  root.render(<FullApp />);
} else {
  hydrateRoot(container!, <FullApp />);
}