memento-dev/app-old/data/snippets/react/reducer/reducer-why-spread-operator.jsx

11 lines
219 B
JavaScript

const initialState = { count: 0, message: "Hello" };
const reducer = (state, action) => {
switch (action.type) {
case "INCREMENT":
return { count: state.count + 1 };
default:
return state;
}
};