react-tutorial icon indicating copy to clipboard operation
react-tutorial copied to clipboard

9. connect 함수 · GitBook

Open utterances-bot opened this issue 5 years ago • 2 comments

9. connect 함수 · GitBook

https://react.vlpt.us/redux/09-connect.html

utterances-bot avatar Jun 18 '20 16:06 utterances-bot

궁금한 점이 있어 댓글로 남겨봅니다!

mapStateToProps 와 mapDispatchToProps 의 호출 시점이 궁금한데요, 최초 렌더링 후 호출된 다음, 상태가 업데이트되면 subscribe 처럼 상태 변화를 감지하고 다시 호출되는 형식일까요?

C17AN avatar Jun 18 '20 16:06 C17AN

@C17AN 님의 댓글을 읽고 저도 공부하는 계기가 되어 답글을 남깁니다. 오래 전이니까 이미 찾아보셨을 수도 있겠네요 :)

https://react-redux.js.org/using-react-redux/connect-mapstate 에 따르면mapStateToProps 는 스토어 상태가 변할 때마다 호출된다고 합니다.

그리고 https://react-redux.js.org/using-react-redux/connect-mapdispatch#defining-the-mapdispatchtoprops-function-with-bindactioncreators 에 따르면 mapDispatchToProps 는 bind된 개별 액션들을 dispatch할 때마다 호출되는 듯합니다.

yeonwooz avatar Aug 01 '21 03:08 yeonwooz