I use Redux in my React app and something is bothering me. The documentation for Redux clearly states that the gearbox must be stateless. You often see such examples:
function reducer(state = { exampleState: true }, action) { switch(action.type) { case "ACTION_EXAMPLE": return Object.assign({}, state, { exampleState: false }); default: return state; } }
My question is, why is this even required? JavaScript is single threaded. In the gearbox there is no chance of a race condition. As far as I can tell, the Redux repository is able to return the current state of the store, so it seems strange that so much attention is paid to pure functions.
source share