💡 react-router (v6.4+) loader
API with react-query
#3655
-
🌕 The
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 11 replies
-
I'll edit this answer more later, don't have much time, but wanted to quickly communicate my thoughts. I've had RQ in mind the whole time while we did this work. Admittedly, I've never used RQ in earnest, so I don't know the intricacies of it's behavior like background fetching, etc. For React Router, the general abstraction is about three things: initiating, mutating, and reading. It maps to React Router like so:
React Router's behavior is pretty simple to explain (though pretty intricate in the implementation)
Next, when an action is called from a form or imperative submission:
Along the way, Remix keeps track of loading and error states. For React Query (with my limited experience with it) I think it looks like this:
I don't know if There is nothing magic about That's pretty much it! |
Beta Was this translation helpful? Give feedback.
-
As Ryan mentioned in his talk, if you're already using react-query, the loader api from react-router gives you a great place to start prefetching. Off the top of my head, there are two things I would keep an eye on:
|
Beta Was this translation helpful? Give feedback.
-
TK Dodo published some "work in progress" example code here using react-router 6.4+ with react-query ✨ |
Beta Was this translation helpful? Give feedback.
-
I've merged the example and written a blogpost about it: |
Beta Was this translation helpful? Give feedback.
I've merged the example and written a blogpost about it: