Tell us what’s happening:
Hi, can you tell me what’s wrong with my code? I can’t understand
Your code so far
// Define ADD, addMessage(), messageReducer(), and store here:
const ADD = "ADD";
const addMessage = mes => {
return {
type: ADD,
message: mes
}
}
const messageReducer = (state = [], action) => {
switch(action.type) {
case ADD:
return [...state, action.message];
default:
return state;
}
}
const store = Redux.createStore(messageReducer);
console.log(store.getState());
store.dispatch(addMessage("Hello"));
store.dispatch(addMessage("hi"));
console.log(store.getState());
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15
Challenge: React and Redux - Extract State Logic to Redux
Link to the challenge: