Next JS error useReducer hook calls twice
I am using useReducer hook on my Next JS Ecommerce project to manage my global state, and I have noticed that whenever I make a dispatch to update my global state it gets called twice, for example when I implemented it on my add to cart functionality, whenever I click on the add to cart button to update the state it increments by two instead of one.
This only happens when you are in a development environment. To stop it all you have to do is go to Next JS config and change react strict mode to false then stop your development server and run it again.
- How to Retrieve the Selected Value from a Select Field in ReactJS and NextJS
- Using bootstrap classes and css styles together in next.js
- Error Cannot find module 'react-dom/client' or its corresponding type declarations
- Resetting form fields onsubmit in next js
- Setting Up CockroachDB in Next.js Projects with Prisma ORM