0

i have a component in which on button click i render a component

 <View style={styles.container}>
    <Text> in Default component!</Text> 
    <Button title="add"
    onPress={this.handelSubmit} />
     {items.map((item, index) => (
         <Home key={index} data={index}  />))} 
 </View>

and my home component look like

 <View style={styles.container}>
    <Text onPress={() => { this.props.navigation.navigate("Calculator")}}>Semester {this.props.data +1}</Text>
  </View>

onPress event i want to navigate to other screen i.e 'Calculator.js' but i got an error undefined is not an object i am using react-navigation for navgation

1 Answer 1

1

If you want to navigate from a component, you have to use your component like this:

<Home key={index} data={index} navigation={this.props.navigation} />
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.