Sneruall / soloswimnl

Webshop for a project that focuses on offering waterproof swimming schedules for in the pool. Using React, NextJS, NodeJS, Stripe, MongoDB and TailwindCSS.
https://www.soloswim.nl
0 stars 1 forks source link

Apply use Context for product page components #51

Open Sneruall opened 2 years ago

Sneruall commented 2 years ago

Many developers tend to think that Context by itself is a state management system. It is not! Context is a dependency injection mechanism. Inside it you can put anything your heart desires, it can become a state management system if you implement it that way. One has to use useState and/or useReducer hook to manage the state inside it. That way, you are deciding where the state lives and you are handling how to update it and where exactly you wish to use it. Context was made exactly to avoid passing data through many layers of components. If you only need to tackle this issue, then just use Context.