Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

94
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!