Use this function if you want to override the previous state with another state based on the current state.
snapshot should never be accessed within reducer. Use the this
of the lambda which is guaranteed to be the current state at the time of execution instead.