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.

message profile
Admin
2023-02-03

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.

Add Message

Click on the button below to add a new message to this thread

Tags

#Javascript #jsx #next js #react js

Thread detail

Satus: Open
Messages: 1Started: 2023-01-06
loading..

DEVMAESTERS

Newsletter

Services

Frontend Development |Backend Development |Full Website Development |Bootstrap Website upgrades | Website Debbugging | Website Hosting & deployment

Contact

Interested in hiring me or collaborating with me on a project, click on any of the links below to get my social media handle

Or contact me via Tel: (+234)-806-225-7480 | Email: abubakarzakari1703@gmail.com

Copywright@devmaesters.com
Privacy Policy

By using our website,
you agree that devmaesters can store cookies on your device and disclose information in accordance with our privacy policy.