Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

96
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda