I was working with React Native and all seem smooth. But suddenly this error occur. I don't know why. Before this, this error not happened. Please help me...
The error is:
TypeError: Cannot read property 'selectedTab' of undefined
The code is below (where the error occur):
function mapStateToProps(state) {
return {
selectedTab: state.tabReducer.selectedTab
}
}
function mapDispatchToProps(dispatch) {
return {
setSelectedTab: (selectedTab) => { return dispatch(setSelectedTab(selectedTab)) }
}
}
export default connect(mapStateToProps, mapDispatchToProps)(CustomDrawer)
It returns that in state.tabReducer.selectedTab, state.tabReducer is null. Make sure tabReducer exists in the state.