blog 406

Discuss in words something you learned in class today or this week.

Lane Garner
2 min readJan 28, 2021

Redux gives us the ability to keep all of the global state in a store as a single state tree/JS object. By using different components such as store, reducer, action, and middleware we are able to set a new state based on user interaction. It can be cumbersome to set up but gaining access to the global state is worth it.

What are “actions” in Redux?

A plain JavaScript object to keep track of the specific event taking place in the application with a ‘type’ property. This action is sent from the UI to the reducer to send a new state. This property lets Redux know what's happening and is later defined as a case in the reducer.

What is the role of reducers in Redux?

A reducer takes the current state of the application and an action to perform on the state and then returns the updated state.

What is the meaning of “single source of truth” in Redux?

We keep a single state tree as a JS object which holds the state of the entire application.

Explain the components of Redux.

The four components in Redux are Store, Reducer, Action, and Middleware. The store holds the complete state tree of our app. A reducer is a pure function that returns the state based on the action dispatched by the store. An action a payload of information that transmits data from an application to a store. They are the sole source of information for the store. Middleware is the suggested way to extend Redux with custom functionality. Middlewares are used to dispatch async functions. We configure Middleware’s while creating a store.

--

--