How can I set onPress event in a child component?

Diego Bittencourt

I have a file called SplashScreen.js with a StackNavigator. Sample code:

enter image description here

Inside my SplashScreen.js I have a component called "Login" and INSIDE Login I have a component called "TouchbleOpacity"

enter image description here

What I need is to change the "onPress" event of my TouchbleOpacity component. So I'll be able to navigate in my Navigator (that are inside my SplashScreen.js). The onPress event should look similar to this: onPress={() => navigation.navigate('TelaCadastrar01')

If there is a better way to change the onPress event of my TouchbleOpacity, please tell me, thanks!

Tim

I don't know if this is what you are looking for, but i'll give it a try:

In your Login Component you do:

//first button
<TouchableOpacity onPress={this.props.onPress} >
    <Text> ... </Text>
</TouchableOpacity> 

//second button 
<TouchableOpacity onPress={this.props.onPressButton2} >
    <Text> ... </Text>
</TouchableOpacity> 

Now you are able to pass any onPress function to your Login Component. e.g.

<Login onPress={() => navigation.navigate('TelaCadastrar01')} onPressButton2={() => console.log('second scene')}/> 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Why can't I see parent state from child component event handler?

From Dev

How can I find is there is child having in tree component or not in PrimeFaces

From Dev

How can I delete parent after click event on child

From Dev

TKinter: How can I set the window icon of a child window (Toplevel)

From Dev

Angular How Can I only trigger child element event

From Dev

How to get onPress event from ScrollView Component in React Native

From Dev

How can I trigger Parent form event from Child form?

From Dev

How to trigger a child component event in componentDidMount

From Dev

How can I delegate a touchesbegan event to an entities component using swift?

From Dev

How can I use an event emitter on a dynamically added component?

From Dev

How can I target router-outlet from a child component?

From Dev

How do I fire a click-event in the child-component?

From Dev

How can I change the state of a parent component from a child component?

From Dev

How can I add events in child component in listview? Is it possible to add event in listview?

From Dev

How can I set state in a child component from a parent?

From Dev

How can I find is there is child having in tree component or not in PrimeFaces

From Dev

How can I delete parent after click event on child

From Dev

How can I modify the props of one child component from a separate child component?

From Dev

How do I fire a click-event in the child-component?

From Dev

How can I change the state of a parent component from a child component?

From Dev

How can I add events in child component in listview? Is it possible to add event in listview?

From Dev

How can I handle redux form submission in child component?

From Dev

How can I update data from parent component when I click child component on the vue component?

From Dev

How can I access from a child component to another child component in Angular 4

From Dev

How can I make a value modified in a child component available to the parent?

From Dev

How can I exclude child class from click event?

From Dev

How do I bind the storeId to an onPress event in React-Native?

From Dev

How can I activate child category in treeview on the vue component?

From Dev

How can I call method in child component from parent component?

Related Related

  1. 1

    Why can't I see parent state from child component event handler?

  2. 2

    How can I find is there is child having in tree component or not in PrimeFaces

  3. 3

    How can I delete parent after click event on child

  4. 4

    TKinter: How can I set the window icon of a child window (Toplevel)

  5. 5

    Angular How Can I only trigger child element event

  6. 6

    How to get onPress event from ScrollView Component in React Native

  7. 7

    How can I trigger Parent form event from Child form?

  8. 8

    How to trigger a child component event in componentDidMount

  9. 9

    How can I delegate a touchesbegan event to an entities component using swift?

  10. 10

    How can I use an event emitter on a dynamically added component?

  11. 11

    How can I target router-outlet from a child component?

  12. 12

    How do I fire a click-event in the child-component?

  13. 13

    How can I change the state of a parent component from a child component?

  14. 14

    How can I add events in child component in listview? Is it possible to add event in listview?

  15. 15

    How can I set state in a child component from a parent?

  16. 16

    How can I find is there is child having in tree component or not in PrimeFaces

  17. 17

    How can I delete parent after click event on child

  18. 18

    How can I modify the props of one child component from a separate child component?

  19. 19

    How do I fire a click-event in the child-component?

  20. 20

    How can I change the state of a parent component from a child component?

  21. 21

    How can I add events in child component in listview? Is it possible to add event in listview?

  22. 22

    How can I handle redux form submission in child component?

  23. 23

    How can I update data from parent component when I click child component on the vue component?

  24. 24

    How can I access from a child component to another child component in Angular 4

  25. 25

    How can I make a value modified in a child component available to the parent?

  26. 26

    How can I exclude child class from click event?

  27. 27

    How do I bind the storeId to an onPress event in React-Native?

  28. 28

    How can I activate child category in treeview on the vue component?

  29. 29

    How can I call method in child component from parent component?

HotTag

Archive