Skip to content
Advertisement

Triggering refresh on function component with navigate (React Native)

One of my screens in my app is a function component which looks like this:

JavaScript

So that onPress you see in DonationItem navigates to another screen called DonationFormScreen. What is in this screen doesn’t really matter except that there is another navigate called in one of its methods:

JavaScript

And last, “Donación confirmada” is a screen DonationConfirmationScreen:

JavaScript

As you see this.props.navigation.navigate("Pedidos") is called inside the button and works fine. What I want to do is not only to navigate back to “Pedidos” (which is my DonationsScreen) but also trigger some sort of refresh, because I need getRequests() to be called again. How can I achieve this?

Advertisement

Answer

Thanks to everyone who answered but I ended up using something else since I couldn’t get the other things to work.

JavaScript

As you see I ended up using isFocused. I had to add this import:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement