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

95
Visualizações
How to use manual cache updates using RTK Query

I have recently started working on redux toolkit, Basically i want to refetch the data from database if there is mutation. I am using flatlist in my react native project where on pull to refresh i want my "getPosts" endpoint to refetch and get updated.

Note: I know about using tags for automated cache invalidation. but on web RTK query is not implemented.

Talking about pessimistic update:

 async onQueryStarted({ id, ...patch }, { dispatch, queryFulfilled }) {
    try {
      const { data: updatedPost } = await queryF`enter code here`ulfilled
      const patchResult = dispatch(
        api.util.updateQueryData('getPost', id, (draft) => {
          Object.assign(draft, updatedPost)
        })
      )
    } catch {}
  }, 

just give a help how to call this function from APP.JS or anywhere from the app. Thanks

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

0

You can just call refetch, you don't need anything that complicated. See the docs on useQuery

const myResult = useMyquery(args)

// in your pull to refresh trigger:
myResult.refetch()

If you are outside of a component, you can also still

store.dispatch(api.endpoints.myEndpoint.initiate(args, { track: false })))

to trigger a refetch

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