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

129
Visualizações
Clear the view cache in Ionic React

I am facing exactly the same problem as this other question where my Ionic react application caches some views so that when a user logs out and logs in directly with another account, they see for a few seconds the previous data (list of news for example) of the previous user. So the solution is to clear all the cached views when the user access the login view.

This solution proposes to add this code in the view:

$scope.$on("$ionicView.enter", function () {
  $ionicHistory.clearCache();
  $ionicHistory.clearHistory();
});

However this is not the same API used in Ionic v5 for react. I could replaced the event listener with:

import { useIonViewWillEnter } from '@ionic/react'

useIonViewWillEnter(() => {
  // ...
})

But what is the equivalent of:

$ionicHistory.clearCache();
$ionicHistory.clearHistory();

I didn't find anything in the official doc so if someone has an idea I will really appreciate some help.

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

0

In the state definition in app.js you can add cache:false to disable caching (See Disable cache within state provider in the Ionic docs. Or, you can keep caching except when you know data has changed.

If you're already on the page, you can do, $state.go($state.currentState, {}, {reload:true})

If you're on another state and want to go back to the state that is normally cached but you want it to be refreshed, you can do, $ionicHistory.clearCache().then(function(){ $state.go('app.fooState') })

Note, the latter requires clearCache to return a promise. See the changes I made in this pull request and compare the implementation of clearCache that you have now with mine: https://github.com/driftyco/ionic/pull/3724

Hope This Works!!

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