Skip to content
Advertisement

Refresh same page with different parameters using React Navigation

I am using React Navigation to navigate between pages. I have a Profile page that contains user info card and that user’s posts. I use Post component inside this Profile component as shown below.

And I have a link button to navigate users profile inside the Post component.

JavaScript

I also use this Post component inside Home Page and navigation is works there without any problem.

My question is the following: When I’m on Profile page and click the navigate button nothing happens. I want to refresh the Profile page with different parameters when the button clicked.(ex: different users profile). How can I do that?

Note: I am fetching the data in Profile page from WEB API using profilId state and useEffect hook:

JavaScript

Advertisement

Answer

Since profileID is changing, your current code would work. All you have to do is to add it as dependency, like so:

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