Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
In React-Native, using navigation.push, how can I keep the data from the previous screens?

What I'm trying to do is very common: I need to navigate between user profiles and being able to go back to each of them.

User1 -> User2 -> User3 And then User3 -> User2 -> User1

To do so, I'm using the navigation.push() method like this :

navigation.push('Profile', {userId: state.userId})

Each time, I call the Profile component, it fetches to relevant data using the userId passed in route.params.

The problem occurs when I want to navigate back. The previous Profile components only display the data of the last fetched user data...

Was my approach wrong ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to keep some kind of global cache which every screen reads from. The data will be up to date if every screen reads from the same place.

The easiest way to do this would be to use react-query for data fetching: https://react-query.tanstack.com/

There are also other options like storing data in Redux after fetching etc.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda