TypeError: Cannot read property 'selectedTab' of undefined

139 Views Asked by At

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

enter image description here

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)
1

There are 1 best solutions below

0
On

It returns that in state.tabReducer.selectedTab, state.tabReducer is null. Make sure tabReducer exists in the state.