Why Wouldn't I Use Redux?

> 2 months ago

This
This Is How I Feel Sometimes

For some reason, people look puzzled when I say that https://www.candlapp.com/ runs on pure react without redux. Why would I? I don't see a problem with passing the state down through props.

I mean it might be a little inconvenient.

But on the other side...

You have to create a store, then reducers, actions. Boilerplate, more boilerplate! And then the action creators cause you don't want to duplicate your code. You had one file, now you have five. And maybe another one with action type constants because they can't just be inline strings. And selectors of cause as we want to be efficient with fetching the required data. And then let's split the tree, combine reducers, connect the components.

Oh wow, redux is synchronous? Well, let's add redux-thunk, or sagas (generators!). Observables anyone?

The amount of typing is crazy. But what's worse, the app is suddenly far away from the simple one-way data flow, because your components can randomly connect to redux, read, and send actions. The props are now trickier as you have to keep in mind if those coming from the parent component or redux? Making sense of where the data is flowing from becomes tricky. Reusing components is harder because they now depend on the particular structure of your state. Testing is problematic.

So no, thank you, I can handle my state on my own.

I do believe there are situations when using a store manager like redux might be beneficial. But that's a rather rare case. In most of the cases, it's the "jQuery-problem" all over again. When people use an abstraction not because it's useful but because they don't know they might not need it.

Weekend JavaScript

Get all the best JavaScript articles in your inbox every Friday. Plus occassional articles like this one. It's Free!
1096 have already joined.