On a redo action, we want to do the following steps:
- Remove the first element from the future
- Insert the current present state at the end of the past
- Set the present to the element we removed from the future in the first step
Replace the return state // TODO line below case actionTypes.REDO: by doing the following:
- First, we check whether there are elements in the future array. If not, we simply return the current state:
if (future.length <= 0) return state
- Next, we store the first element from the future because we will need it in the last step:
const next = future[0]
- Then, we create a new array from the future array, with the first element excluded:
const newFuture = future.slice(1)
- Next, we create a ...