깊은 하위컴포넌트들도 props 없이 모든 컴포넌트가 state를 갖다쓰기 가능1 . import { Provider } from 'react-redux';import { createStore } from 'redux';<Provider>로 <App /> 감
state 데이터 관리가 용이하다.redux에선 state데이터의 수정방법을 미리 정의 : reducer 함수reducer함수는 수정된 state를 리턴해주는 함수이다let store = createStore(reducer);기본 데이터를 다른 변수에 할당한다.redu
combineReducers(index.js에서) 다른 종류의 state를 저장하고 싶으면 reducer를 더 만들면 된다. reducer를 더 만들었으면 createStore()안에 넣어야함. 이때 필요한 것이 combineReducers import { comb
dispatch()로 수정요청할 때 데이터를 보낼 수도 있다.props.dispatch({ type: 타입명, payload: 보낼데이터 })action 파라미터 범위보낸 데이터는 reducer함수 두번째 파라미터인 action에 저장되어 있다.A.jsindex.jsc
state꺼내쓰는 더 쉬운 방법 : useSelector();export default A; 다시 바꾸준다.import { useSelector } from 'react-redux';let state = useSelector((state) => state)console