Redux reducers are pure functions. That means, they have no side-effects. Given the same arguments, the reducer must always generate the same shape of state. Take for example the following reducer function:
const reducer = (prevState, action) => { if (action.type === 'INC') { return { counter: prevState.counter + 1 } } return prevState }
If we execute this function providing the same arguments, the result will always be the same:
const a = reducer( { counter: 0 }, { type: 'INC' }, ) // Value is { counter: 1 } const b = reducer( { counter: 0 }, { type: 'INC' }, ) // Value is { counter: 1 }
However, take into account that even though the returned values have the same shape, these are two different objects. For instance, comparing the above:
console.log(a === b) returns false...
console.log(a === b) returns false...