- redux로 부터 import
- 스토어를 만드는 함수
src > redux > store.js 우선 하기전에 npm i redux
redux 설치
// store.js
import {createStore} from "redux";
import {todoApp} from "./reducers";
export const store = createStore(todoApp);
최상위 index.js에서 store 값 확인
// index.js
const unsubscribe = store.subscribe(() => {
console.log(store.getState()); // ['밥 먹기], ['밥 먹기', '잠자기'];
})
store.dispatch(addTodo('밥 먹기'));
store.dispatch(addTodo(' 잠자기'));
unsubscribe();