로딩
요청 처리 중입니다...

[Redux] Vanilla JavaScript에 Redux 적용하기(action) #1

 [Redux] Vanilla JavaScript에 Redux 적용하기(action) #1

const reducer = (state = 0, action) => { //state = 0은 default값 console.log(state, action); return state; }; const store = createStore(reducer); action은 reducer의 두번째 인자로 받아지며 state를 modify할 수 있다. action is a way that communicate with reducer. 그럼 어떻게 action을 사용할 수 있나. const reducer = (state = 0, action) => { console.log(state, action); return state; }; const store = createStore(reducer); store.dispatch("HELLO"); //dispatch()를 사용.

Actions must be plain objects 라고 한다. const reducer = (state = 0, act...

# action # dispatch # redux # store # 리덕스