kgneng2 / blokg

blog
MIT License
0 stars 0 forks source link

React #34

Open kgneng2 opened 3 years ago

kgneng2 commented 3 years ago

생명주기

초기화

업데이트

hook

kgneng2 commented 3 years ago

Redux

image

Action

// action생성자 함수
function addTodo({title, property}){
  return { type: 'todo/ADD', title, property}
}

invoke action

store.dispatch(addTodo(titile,property))

middleware

const middleware = store => next => action => next(action)

const store =createStore(myReducer, addMiddlewarre(mi1,mi2...) 요런식으로 추가할수 있음.

reducer

function reducer(state = INITIAL_STATE, action) {

  switch(state) : {
  //action 정의

 }
}

store

kgneng2 commented 2 years ago

mapStateToProps() 함수에서 return 된 값이, 해당 컴포넌트의 props로 들어간다. 이 mapStateToProps함수를 마지막 줄 connect의 첫 번째 인자로 넣어줘야 한다.

우선 이 mapDispatchToProps()함수도 mapStateToProps() 함수처럼 리턴된 값이 props로 넘어간다.

참고: https://helloinyong.tistory.com/109