Tell us what’s happening:
I have the following code and I ‘think’ I am copying the array right way but is not letting me pass the test
Dispatching an action of type
ADD_TO_DO
on the Redux store should add atodo
item and should NOT mutate state.
What am I missing?
Your code so far
const immutableReducer = (state = ['Do not mutate state!'], action) => {
switch(action.type) {
case 'ADD_TO_DO':
// Don't mutate state here or the tests will fail
let copiedState = [...state];
return copiedState;
default:
return state;
}
};
const addToDo = (todo) => {
return {
type: 'ADD_TO_DO',
todo
}
}
const store = Redux.createStore(immutableReducer);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Challenge: Redux - Use the Spread Operator on Arrays
Link to the challenge: