reading-notes

Reading notes about code for my future reference.

View the Project on GitHub

useReducer hook

Name an alternative to the useState Hook.

We can utilize the useReducer hook!!!

Why might the useReducer Hook be preferable to the useState Hook?

useReducer hook is more for more complex logic. Than having a simple value like when you have to use the useState Hook.

What are two ways to set the initial state?

Inside the constructor or directly inside the class.

Ultimate Guide to useReducer

In terms of state, what does useReducer expect to receive as a parameter?

It takes in the intial value for state and it utilizes the reducer function.

What does useReducer return?

Just like the useState hook, the useReducer hook returns an array.

Explain dispatch to a non-technical recruiter.

It allows you to pass in a group of data and it represents what action we want to use for them. It tells the reducer what to do which is essentially to update state.