[ JS Library/React ]
Context API 활용 상태 관리
2022-08-03 14:53:23
앞의 게시글과 이어지는 context API reducer 를 만들겠음ㅇ TodoContext.js import React, {useReducer} from "react"; const initialTodos = [ { id: 1, text: '프로젝트 생성', done: true }, { id: 2, text: '컴포넌트 스타일링하기', done: true }, { id: 3, text: 'Context 만들기', done: false }, { id: 4, text: '기능 구현하기', done: false }, ] function todoReducer(state, action) { switch (action.type) { case 'CREATE': return state.concat(action.tod..