0

I m getting TypeError: undefined is not an object(evaluating 'navigation.state')in React Native.

const DashboardFooter = ({navigation}) => {
      const activePage = navigation.state.index;
      return (
           <TouchableOpacity
            style={styles.tabIconContainer}
            onPress={() => navigation.navigate('Dashboard')}>
            <Image
              source={
                activePage === 0
                  ? require('../assets/images/dashboard/menu.png')
                  : require('../assets/images/dashboard/menu-active.png')
              }
              style={{width: 24, height: 24}}
             />
            <Text style={styles.titleMenu}>Menu</Text>
          </TouchableOpacity>
        );
    };

I m getting this errorenter image description here!

1

1 Answer 1

1

Cross posting from here:

It seems like you're not properly creating the component so that the navigation property is set. You'll need to make sure to wrap the component using the withNavigation higher order component.

export default withNavigation(MyComponent);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.