Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- useEffect
- useParams
- redux 사용방법
- JavaScript
- react redux
- react
- 인라인블럭
- 자바스크립트
- React onClick
- redux toolkit
- javascript코딩테스트
- toString
- 협업프로젝트
- React state
- sort
- first-child
- 6주포트폴리오
- useSearchParams
- db.json
- foreach
- 콜백함수
- 카우치코딩
- JSON
- 블럭요소
- javascript React
- couchcoding
- Redux store
- line-through
- 자바스크립트배포
- Redux
Archives
- Today
- Total
개발하는 루루언니
redux 셋팅 본문
728x90
반응형
< store >
import { createStore, applyMiddleware} from "redux"
import thunk from "redux-thunk"
import {composewithDevTools} from "redux-devtools-extension"
let store = createStore(rootReducer, composewithDevTools (applyMiddleware(thunk)) )
해석
1. store안에는 첫번째 reducer이 들어감
2. api 호출을 위한 어플라이 미들웨어
3. 넣어줄 미들웨어는 thunk다
4. 쉽게 개발을 하기 위한 툴 > devtool을 이용하기위해 composewithDevTools 의 매개변수를 미들웨어를 넣어준다.
redux 폴더안에 reducer 폴더를 만들어주고 index.js를 만든다.
------------>rootReducer 을 가져오는 작업
combineReducers 는 여러개의 reducer을 하나로 합치는 작업을한다.
<reducer > 폴더안에 index.js
import {combineReducers} from "redux"
export default combineReducers({})
combineReducers은 항상 객체가 들어갑니다. 객체안에 reducer을 여러개 만들거입니다.
store " root Reducer을 reducer 폴더안에 있는 앞으로 만들 index 애들로 불러옵니다)
import { createStore,applyMiddleware} from "redux"
import thunk from "redux-thunk"
import {composewithDevTools} from "redux-devtools-extension"
import rootReducer from "./reducers"
let store = createStore(rootReducer,composewithDevTools(applyMiddleware(thunk)) )
728x90
'컴퓨터 정보 > 리액트' 카테고리의 다른 글
자바스크립트 함수로 기본 문제 응용해보기 (0) | 2022.11.05 |
---|---|
리엑트 : map 의 화살표 => 뜻 (0) | 2022.11.04 |
css가 적용안될때 (0) | 2022.11.01 |
로딩 스피너 만들기 (0) | 2022.11.01 |
슬라이드로 만들고 싶으면? react-multi-carousel (0) | 2022.11.01 |