Unshift data to array in Redux reducer

Viewed 1807

On the dispatch of the UPDATE_DATA action, I am able to push data to my state.data array in the reducer with the following code.

const toPush = {
    name : "Pushed Name",
    id_name : 100,
    more1 : "pushedMore01"
}

case "UPDATE_DATA":
  return {
    ...state,
    data: [...state.data, toPush],
    isFetching: false
}

How do I unshift rather than push the data to state? What would be clean ES6 syntax for the same?

1 Answers
Related