Home > Software design >  Error in production after upgrading to react 18
Error in production after upgrading to react 18

Time:04-22

I am trying to update dependencies in this Next JS Starter Console error log screenshot

In production they switch from react to preact https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/41839607af9db071eadb60fa9fc4ffb4942661cf/next.config.js#L75toL83

But the issues occurs after upgrading react only preact is left unchanged

To reproduce just clone the repo and change react and react-dom version to 18.0.0

After building your site when navigating you will see the issue

CodePudding user response:

Preact doesn't yet shim the new hooks in React v18. You'll need to revert usage of the new hooks.

You can track the following issue which adds the hooks to Preact: https://github.com/preactjs/preact/pull/3510

Side note: you really should be using Preact in dev too. Switching between runtime libs in dev vs. prod makes you extremely prone to running into small inconsistencies between them. Switching to Preact only in prod is a really bad practice that's somehow gotten popular in NextJS.

  • Related