You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Its just a new create-next-app with usehooks-ts installed and utilizing useDarkMode which internally rely's on useIsFirstRender
Possible reason :
Maybe it's because Nextjs might be running useIsFirstRender in server before serving it to client, saying this because I came across this vercel/next.js#52566 (comment) which states some hooks can be ran on server like useId etc and useRef might be one of them 🤔 but I maybe completely wrong here !!
Update :
It seems that disabling reactStrictMode in App router solves the issue but its bad idea to do so :(
The text was updated successfully, but these errors were encountered:
Demo :
It seems that
useIsFirstRender
always returnsfalse
in NextJs App router, here is an example :Screen.Recording.2023-10-03.at.2.48.58.PM.mov
So
localhost:8080
serves the page fromapp
dir andlocalhost:8080/pagedir
serves it frompages
dirAs we can see when on
localhost:8080
useUpdateEffect
runs directly instead onlocalhost:8080/pagedir
it does not since its it first renderhere is minimal reproducible repo : https://github.com/technophile-04/useIsFirstRender-mrr
Its just a new create-next-app with
usehooks-ts
installed and utilizinguseDarkMode
which internally rely's onuseIsFirstRender
Possible reason :
Maybe it's because Nextjs might be running
useIsFirstRender
in server before serving it to client, saying this because I came across this vercel/next.js#52566 (comment) which states some hooks can be ran on server likeuseId
etc anduseRef
might be one of them 🤔 but I maybe completely wrong here !!Update :
It seems that disabling
reactStrictMode
inApp router
solves the issue but its bad idea to do so :(The text was updated successfully, but these errors were encountered: