0

Hi I am new to React native and React native navigation. I am using react navigation screen to show details about users. I have around 100 different users. I am navigating to the next user by using push instead of navigate as I have to pass different props (same screen, different parameters).

navigation.push('UserDetails', {id: id + 1})

This method is mentioned in the documentation and this thread:

React-Navigation go to same route with different params

However, as there are a lot of users, this ends up creating a lot of screens on the stack and creates performance issues and crashes. Is there any other way to implement this?

  • Please explain it a little bit more. As for my understanding, you have 1 screen where users are listed. And clicking on any User you are showing that user details. If yes then use navigation.navigate('UserDetails',{id}). And in "UserDetails" call api for that user to get details of that user – Naveed Khan Apr 02 '23 at 00:29
  • Yes your understanding is correct. But as I mentioned, I have around 100 students. I navigate to the next student with a button in UserDetails page. This will take me to same page with different props. Home -> UserDetails(id) -> UserDetails(id+1) -> UserDetails(id+2)... – Aadhavan Lenin Apr 03 '23 at 11:55
  • I tried using `navigate`, but it does not update the page with the new props. So I am forced to use `push`. Is there any other way to solve this? – Aadhavan Lenin Apr 03 '23 at 11:58

1 Answers1

0

You don't need to use navigation for this purpose. You need to triger screen update according to user id (at screen state or Redux Store).

M.N.
  • 65
  • 8