It's time to ditch Medium for good! 🌈⚡️

Introducing Devblog by Hashnode. Blog on your domain for FREE. Highly customizable and optimized for developers.

Learn more

Ask anything to Redux

Redux is a predictable state container for JavaScript apps. Andrew Clark, co-creator of Redux, is hosting this AMA to answer any questions you might have. Andrew recently joined Facebook as a front-end engineer. It's a great opportunity for everyone to get in touch with Andrew and have his insights on Redux and various other topics.

Ask Redux about:

  • Redux
  • State management in React/JavaScript based apps
  • Recompose Library
  • Working at Facebook
  • Anything related to React, JavaScript etc

Hosted by:

Ask a Question

68 discussions

When did you start realising that Redux was gaining popularity, and being used in production level apps? What were your feelings? What would be your advice for an open source aspirant?

Show all replies

I knew Redux would be popular pretty much the moment I saw Dan's original version. I had a semi-popular (at the time) Flux library called Flummox, so it would have been easy for me to be stubborn and deny the obvious benefits of a reducer-based Flux. In one of my proudest moments, I instead quickly deprecated Flummox and jumped on the Redux train. Zero regrets. I caught some flak for this (reasonably—I could have done a better job transitioning Flummox users to Redux) but it ended up being a great decision, both for me personally and for the Redux community as a whole.

So my open source advice is this: you are not competing against other libraries. Well, I mean, you are, but if you focus mostly on "beating" the other guys and gals, you're eventually going to fail. Work on finding the best solutions, regardless of whether that's by collaborating on someone else's project or starting your own.

Reply to this…

Share your programming knowledge and learn from the best developers on Hashnode

Get started

Hi Andrew.

I'm going to start using Redux with React and in the process I want to understand how React/Redux and ideas from functional programming fit together.

Would it be better to work with Elm first and then after I've understand big picture shifted back to React/Redux?

I recommend learning Elm to pretty much every front-end developer. It's great that FP-style patterns in JavaScript have become more popular, and I'm absolutely thrilled that Redux has played a part in it, but there's only so much FP you can do in JS given the limitations of a language. Elm is an ML-style, purely functional language, so you'll get to learn things like pattern matching, algebraic types, and "immutability everywhere" that aren't possible with JavaScript.

Whether you learn Redux or Elm first probably varies from person to person. Dan and I both didn't really understand Elm until after we had created Redux and "accidentally" (subconsciously?) borrowed some of its ideas. We've heard from other people who report the same. So if learning Elm is overwhelming, give Redux a try and go back to Elm later to get the full experience.

Reply to this…

Hi Andrew, You've got hired by Facebook just recently, Congratz! What are your responsibilities and how is Redux affected if its affected at all.

I'm only in my third week so I'm still in Bootcamp. (Bootcamp is Facebook's onboarding program for new engineers. It typically takes about 6-8 weeks, and it's used to both familiarize yourself with Facebook's product and engineering practices, and also to help you figure out what team you want to join.) Once I'm done with Bootcamp, I'll be joining the React team—which is exciting for many reasons, including that I'll be on the same team as Dan!

I doubt Redux will be be affected. However, one of the negative consequences of Redux's phenomenal success has been a trend away from using React's component state. There's a common misconception that using component state is bad or an anti-pattern because it's not as pure or functional as a Redux reducer. But not everything belongs in a global Redux store, and local component state is often the more appropriate place for many kinds of state in your app. I believe what people are really responding to is the awkwardness of the setState API, which has some edge cases and quirks that can be confusing. (See this Twitter thread for an example: The React team is interested in exploring ways to make the state API more functional and "Redux-y."

Reply to this…

Hi Dan, you often say that the Redux is inspired by a few core ideas in Elm; could you give a brief on what parts of Redux were inspired by Elm?

I would say that some aspects of Redux are similar to Elm Architecture ( In particular, Redux reducers are similar to "update" functions in Elm, and Redux combineReducers() is a helper for a pattern that is also used for creating a hierarchy of update functions on Elm. The major difference is that Elm Architecture is "fractal", that is, it usually describes hierarchical UI, and like React components, always nestable. In Redux, however, there is always a top-level "entry point" (store), and so some things inherently live on the top level (such as middleware). This makes it harder to reuse components coupled to Redux because they assume a specific top--level state shape, or a specific middleware. Elm Architecture also models complete UI, whereas Redux is typically used solely for the "model", and the role of UI is often given to React. The differences between React composition model and Redux also contribute to React/Redux being less cohesive as a whole than Elm Architecture. As for historical context, neither me nor Andrew fully understood Elm Architecture when we were working on Redux, and only realised the similarities post factum. Nevertheless we're happy to direct people interested in such patterns to Elm which is worked on by smarter people than us.

Reply to this…

Thanks for the detailed answer to my last question! Do you think complex apps can be built without a state management solution like Redux?

You can get pretty far without a state management solution like Redux, but for any non-trivial app, I wouldn't recommend it. But as I've said in a few responses already, I don't think it's wise to put everything into your Redux store.

The rule of thumb I follow is: when in doubt, implement your state using React component state (that doesn't mean you can't use a reducer). Only move it into Redux once it becomes necessary.

Reply to this…

Load more responses