-
[Redux] redux createStore 취소선과 해결 방법📌 React 2022. 10. 18. 16:36
문제
리덕스를 사용하려고 하는데
createStore에 취소선이 그어져있다.import { createStore } from "redux"; const store = createStore(rootReducer, composeWithDevTools);
import {
createStore} from "redux";const store =
createStore(rootReducer, composeWithDevTools);원인
이유는 createStore 를 더이상 사용하지 않기 때문이라고 한다.
위 설명에 따르면)
createStore를 대체하는 @reduxjs/toolkit 패키지의 configureStore 메소드를 사용하는 것이 좋다.
Redux 툴킷은 스토어 설정, 리듀서, 데이터 가져오기 등을 포함하여 Redux 로직을 작성하는 데 권장되는 접근 방식이다.
자세한 내용은 다음 Redux 문서 페이지를 참조. https://redux.js.org/introduction/why-rtk-is-redux-today해결
설치
1. 프로젝트 생성 시 redux 추가
npx create-react-app my-app --template redux
2. 기존 프로젝트에 추가
# NPM npm install @reduxjs/toolkit # Yarn yarn add @reduxjs/toolkit
configureStore
createStore대신 configureStore를 가져와 사용했다.https://redux-toolkit.js.org/api/configureStore
configureStore | Redux Toolkit
redux-toolkit.js.org
https://github.com/reduxjs/redux-toolkit/issues/282
configureStore fail with redux-saga: you must mount the Saga middleware on the Store using applyMiddleware · Issue #282 · red
I'm configuring my store with redux-saga but I'm getting the next error: Error: Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware the configuratio...
github.com
반응형'📌 React' 카테고리의 다른 글
[React] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined 에러 (0) 2022.10.14 [React] Todolist 만들기 정리(3) (0) 2022.09.29 [React] Todolist 만들기 정리(2) (0) 2022.09.28 [React] Todolist 만들기 정리(1) (0) 2022.09.28 [React] Context API (0) 2022.09.27