const mapStateToProps = state => {
return {
darkMode: state.darkMode
}
}
// redux에 담겨 있는 state를 사용하기 위한 map 설정
const mapDispatchToProps = dispatch => {
return {
changeTheme: () => dispatch(this.props.changeTheme())
}
}
// redux에 담겨 있는 dispatch를 연결해주기 위한 map 설정
export default connect(
mapStateToProps,
mapDispatchToProps
)(ContentItem)
// 위에서 설정한 두개의 map을 연결하기 위한 connect 설정
'리액트,타입스크립트' 카테고리의 다른 글
javascript key값으로 배열 묶기 (groupby) (0) | 2022.04.20 |
---|---|
React.memo 활용법 (0) | 2021.06.30 |
React 이벤트 핸들러 전달 (0) | 2021.04.15 |