React.js (18) 썸네일형 리스트형 React Redux 기초 2 - reducer 여러개 쓰기(combineReducers) 저번 글에서 reducer는 state바꾸는 함수라고 알려줌 근데 저번 글처럼 만들면 reducer 1개밖에 못쓰잖음 그럼 app에서 전역변수는 1개 쓸꺼임? 그럴 때 쓰는게 combineReducers 이거임 쓰는 법 import { combineReducers } from 'redux'; import counter from './counter'; import todos from './todos'; const rootReducer = combineReducers({ counter, todos }); export default rootReducer; 1) redux에서 combineReducers 데리고옴 2) 변수하나 만들어서 combineReducers 호출하고 안에다가 넣고싶은 reducer 다 넣.. React Redux 기초(Counter App 만들기) with Typescript react와 typescript 설치하기 npx create-react-app . --template typescript create-react-app으로 react를 설치할 때 --template typescript 붙이면 typescript로 react 설치된다. redux 설치하기 npm i redux --save --save 붙이면 라이브러리 설치할 때 package.json에는 적용안되고 package-lock.json에는 적용되서 동작은 하는데 확인이 어려울 때를 방지할 수 있다. App.tsx 기본 구성 만들기기본 내용 지우고 글자랑 버튼 두 개를 만들어 줬다function App() { return ( Clicked: times + - ); } reducer 만들기const counter .. 이전 1 2 3 다음