trying my hand on redux as a new react developer. i want to dispatch an action passing it a string that will update the text property as a new state.
Here is how i have done it.
const notesReducer = (state = 'Initial State', action) => {
switch(action.type) {
case "ADD_NOTE":
return({
text: action.text
})
default:
return state;
}
};
const addNoteText = (note) => {
return ({
type: "ADD_NOTE",
text: note
})
};
const store = Redux.createStore(notesReducer);
console.log(store.getState());
store.dispatch(addNoteText('Hello!'));
console.log(store.getState());
The action creator addNoteText() takes in an argument to pass to the text property. please help