score:2

Accepted answer

You can use Array.slice which returns a shallow copy of your original array minus the sliced items. DO NOT use shift() which actually mutates your state and can cause all sorts of issues.

return [...state.slice(1), action.payload.stream]

score:0

Array#shift returns the shifted value, not the array with the value removed (it shifts it in-place).

You can do

state.shift()
[ ...state, action.payload.steam ] 

although I'm pretty sure Redux docs specify that you should avoid acting on the state directly...


Related Query

More Query from same tag