const reducer = (state, action) => {
switch (action.type) {
case "EDIT": {
return action.data;
}
//...생략
}
}
function App() {
const [state, dispatch] = useReducer(reducer, []);
const onEdit = (targetId, date, content, emotion) => {
dispatch({
type: "EDIT",
data: {
id: targetId,
date: new Date(date).getTime(),
content,
emotion,
},
});
};
//...생략
}
공부하며 정리&기록하는 ._. 씅로그