[Redux] useSelector, useDispatch

cho yunsu·2021년 9월 19일
0

useSelector ?

  • useSelector is a function that takes the current state as an argument and returns whatever data you want from it. It's very similiar to mapStateToProps() and it allows you to store the return values inside a variable within the scope of you functional components instead of passing down as props.
 const sidebarShow = useSelector((state) => state.sidebarShow);

useDispatch ? dispatch를 날리는 것. action을 날리면 된다.

react-redux 7버전 이후 부터 생긴 훅으로 인해 connect HOC를 사용하지 않아도 된다.

profile
Growing Developer!!

0개의 댓글