Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The Nextjs state is not updating when the route is changed because Nextjs uses server-side rendering and client-side rendering. When the route changes, the client-side rendering takes over but the state is not carried over from the server-side rendering. Therefore, if you want to update the state when the route changes, you need to use a React hook or a global state management library such as Redux or MobX.