Professional learning NextJs useContext in the easiest possible way for those who have tried any other ways.
$ npx create-next-app@latest source: https://nextjs.org
✔ What is your project named?learn_usecontext
✔ Would you like to use TypeScript? [Yes]
✔ Would you like to use ESLint? [Yes]
✔ Would you like to use Tailwind CSS? [Yes]
✔ Would you like to use src/
directory? [Yes]
✔ Would you like to use App Router? (recommended) [Yes]
✔ Would you like to customize the default import alias (@/*)? [No]
$ cd learn_useContext $ npm i
npm run dev http://localhost:3000
https://github.com/Medic1111/monstera-shop-client-only-typescript
what is use client?
https://react.dev/reference/react/use-client https://nextjs.org/docs/app/building-your-application/rendering/client-components
useContext values gets cleared during page refresh and logout!
How to instantly update state when any changes into the localstorage in React.js?
How to Fix "localStorage is not defined" in Next.js?
https://stackoverflow.com/questions/52474208/react-localstorage-is-not-defined-error-showing https://developer.school/snippets/react/localstorage-is-not-defined-nextjs
Why we need to pass a function to React setState() method?
https://iq.js.org/questions/react/why-we-need-to-pass-a-function-to-setstate
using useContext with custom hooks vs useContext + useReducer
https://dev.to/clickpesa/react-manage-state-using-context-api-with-usestate-or-usereducer-hooks-d5l https://stackoverflow.com/questions/70455690/using-usecontext-with-custom-hooks-vs-usecontext-usereducer
useContext + useReducer
https://designcode.io/react-hooks-handbook-usereducer-with-usecontext-1 https://designcode.io/react-hooks-handbook-usereducer-with-usecontext-2
useReducer vs Redux
https://blog.saeloun.com/2023/08/31/react-state-management-usereducer-vs-redux/