T
TanStack•3y ago
magic-amber

React Query vs React's Context API

Hey folks, I'm using React Query in a project and the idea is to use this in place of context providers. However, my question is, whether having both in a project is suitable? I understand they have different purposes, but it would be great if someone could outline when you would use one over the other (or use both for that matter). Also, I have an example where I feel like using React Query is overkill, but would appreciate some feedback. The issue is, there is a page where a user selects an option in a dropdown and clicks on a button to continue their journey. I use the useState hook and the context API to store the value of the dropdown, in order to access it on the following pages. In this instance, would I be able to do this using React Query?
3 Replies
conscious-sapphire
conscious-sapphire•3y ago
Hi 👋 Yes, they can be used together. They aren't alternatives for one another. To answer your other question: React Query is an asynchronous state management tool. This doesn't sound like asynchronous state so I don't think it solves anything for you here.
magic-amber
magic-amberOP•3y ago
Cheers Louis - thanks for answering my question
conscious-sapphire
conscious-sapphire•3y ago
No problem :reactquery:

Did you find this page helpful?