How can I know if I need React Query?
This is because server state is totally different.
React component
React component
React component
React component
projects
React component
React component
React component
React component
projects
query
query
query
query
read
create
update
delete
React component
React component
React component
React component
query
query
query
query
read
create
update
delete
projects
React component
React component
React component
React component
projects
query
query
query
query
read
create
update
delete
queryCache
// whenever we call useQuery('myQueryName', service.getData)
// React-Query does this under the hood
// (simplified)
getResolvedQueryConfig(config); // gets the query from the queryCache.
new QueryObserver() // new instance of their own Observer implementation.
// Subscribe to the observer
React.useEffect(() => {
errorResetBoundary.clearReset()
return observer.subscribe(() => {
if (isMounted()) {
rerender()
}
})
}, [isMounted, observer, rerender, errorResetBoundary])
// more stuff, like handling Suspense
const result = observer.getCurrentResult()
// Gives us an instance of QueryResult, a prop in the QueryObserver class
// which has the callbacks in case another query has been modified
// or set to "stale" to fetch the data again, and more stuff.
return result;