Hacker News new | ask | show | jobs
by acemarke 3027 days ago
I'll agree with the "nothing magical" statement, but I disagree with most of the rest of that comment.

Certainly there's nothing "magical" about Redux. After all, the core `createStore` function can be written in about 25 lines if you leave out error handling, and the entire core lib in about 100 lines [0]. React-Redux does have a ton of optimization work internally, but conceptually it's pretty simple too - components subscribe to the store, call getState(), extract what they need, and re-render [1]. And that's the great thing: Redux is, as its tagline says, "a _predictable_ state container" - there _is no magic_ involved.

What a lot of people don't seem to realize is that the Redux core is a _starting point_. One of my favorite quotes is:

> "Redux is a platform for developers to build customized state management for their use-cases, while being able to reuse things like the graphical debugger or middleware"

We encourage Redux users to use whatever abstractions are appropriate for their own applications, including writing their own. In addition, Redux was designed from the ground up to be extensible [2]. As a result, the Redux ecosystem has exploded. My Redux addons catalog [3] lists somewhere around 2000 Redux-related libraries, utilities, and tools, ranging from action/reducer generation utils to side effects management addons to abstractions for fetching data from REST APIs.

I've seen dozens of "Redux, but.." knockoffs. Most of them wind up throwing away the key design decisions that make Redux special. In particular, the concepts of plain object actions and reducer functions are what truly enable time-travel debugging and easy serialization of state.

My current estimate is that somewhere between 50-60% of React apps currently use Redux. Redux has gained adoption in the Angular, Ember, and Vue communities as well, and inspired dozens of similar libraries, like NgRx, VueX, and more.

Sure, I expect that some of that "market share" will slip over time, especially with the release of the new React context API soon. But, I also feel safe in saying that Redux will be around for a long time.

[0] https://gist.github.com/gaearon/ffd88b0e4f00b22c3159

[1] https://gist.github.com/gaearon/1d19088790e70ac32ea636c025ba...

[2] http://blog.isquaredsoftware.com/2017/09/presentation-might-...

[3] https://github.com/markerikson/redux-ecosystem-links