It's easy to look at Redux and think it's just an overcomplicated global state. You can strip away much of the API and just implement an immutable object state, even mimicking the React state API of just setState
and getState
.
And, this will get you pretty far. Then, throw in a few helpers to map or select parts of the state object and use them as props in your Components, and you actually have a solution that's very friendly for rapid prototyping. Without the need to create specific Actions and Reducers, you reduce boilerplate, and can just start modifying state from your components: globalStore.setState({todos: globalState.todos.push(newTodo)})
.
When creating prototypes or MVPs, where speed is a priority, a simple global store is a good solution. So, why would you bother with the added complexity of Redux, Actions, and Reducers? Well, here's what I've come up with.