August 2017
Beginner
374 pages
10h 41m
English
Let's say, we want to insert an item at the index i. First, we create two slices:
Then, we create a new array from the first slice, our new item, and the second slice:
const insertItem = (state = [], action) => { const i = action.index const item = action.item return [ ...state.slice(0, i), item, ...state.slice(i) ]}
Read now
Unlock full access