As (a) component grows, so does the amount of state logic sprinkled throughout it. To reduce this complexity and keep all your logic in one easy-to-access place, you can move that state logic into a single function outside your component, called a “reducer”.
Managing state with reducers is slightly different from directly setting state. Instead of telling React “what to do” by setting state, you specify “what the user just did” by dispatching “actions” from your event handlers. (The state update logic will live elsewhere!) So instead of “setting tasks” via an event handler, you’re dispatching an “added/changed/deleted a task” action. This is more descriptive of the user’s intent. https://react.dev/learn/extracting-state-logic-into-a-reducer
Reduce, it takes in two arguements and returns one.
If you only need a simple state value without any complex logic, then useState will be enough. On the other hand, if your state needs more complex logic or multiple values that interact with each other, then using useReducer would be beneficial. https://www.frontendmag.com/tutorials/usereducer-vs-usestate/
Keep these pages handy - they answer questions that show up regularly for this lab.
useReducer hook Keeping Components Pure Queueing a Series of State Updates
I want to know how to use this, the article specificed that it has to be ‘pure’ but that it could also be used in conjunction with useState as well…