Redux for Beginners Learn Redux Basics with Code Examples

December 23, 2021

Redux has a very well explained guide that can help you get started. Now we're going to listen to any changes in the store, and then console.log() what does redux do the current state of the store. When you're learning Redux, there are a few core concepts that you need to get used to.

  • Instead, we dispatch actions that intend to change the state, and then separately, we observe the resulting state changes.
  • The bindActionCreators() helper provided by Redux can be used within this function to bind action creators to the store’s dispatch method.
  • With that in place, what’s left is dispatching this action when a user clicks a user, and doing something with the dispatched action within our reducers.
  • For instance, the add function below uses a global state to calculate its output.
  • For large scale apps, it’s critical to keep your app more predictable and maintainable.

If you’re going to use Redux you should know how functional programming works. Redux was built on the principles of functional programming and understanding functional programming concepts will give you insight on how Redux operates the way it does. Since Redux doesn’t allow your application to make changes to the state and uses dispatch() to do that instead. Dispatch() just indicates an intent to change the state, it doesn’t actually change it… that’s where Reducers come in. If we had left our components communicating with each other, we would have created an error prone and unreadable codebase.

Set the store prop on the container component

Similar to (and inspired by) Facebook's Flux architecture, it was created by Dan Abramov and Andrew Clark. Since mid-2016, the primary maintainers are Mark Erikson and Tim Dorr. React is generally fast, but by default any updates to a component will cause React to re-render all of the components inside that part of the component tree.

For example, the same type of field is written multiple times which is not good as per the DRY principle in programming. To keep our code DRY we need to look at the new term Action Creators. That is the reason we have defined all three actions with the same type of field.

Redux is maintainable

If you build a game with Redux, you'd just need a couple more lines of code to save/load the game progress, without changing the rest of the code. Because Redux requires every action to be described in clear text, the support for undo/redo almost comes for free. The instructions of how to implement undo/redo with Redux fit in a simple page. Keep an eye on the recent development of React, though. As with the "context" API, there might be a new "setState" API in a future version of React. It'd make it easier to break up complex update logic into smaller parts.

what does redux do

Our Values

Get started

Your first point of contact

Would you like to know more about what life’s like at MIT ? Chat with one of our staff to hear about the experience.
Additional information, brochures and forms can be mailed to you upon request.
Request information

Interested in becoming an MIT student?

We have a rolling admission process.
Check out the entry requirementsApply for admission 


We hold frequent informational events for parents and prospective students.
See our calendar of events
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram