Why is this not being accepted? action.payload
Considering that action is an object, why can’t I access the payload this way?
Your code so far
// Define ADD, addMessage(), messageReducer(), and store here:
const ADD = 'ADD';
const addMessage = (msg) => {
return {
type: ADD,
payload: msg
}
};
const messageReducer = (state = [], action) => {
switch(action.type) {
case ADD:
return {
...state,
action.payload
}
default: return state;
}
}
const store = Redux.createStore(messageReducer);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
.
Challenge: Extract State Logic to Redux
Link to the challenge: