Client side routing via react-query
It might be a controversial idea. But after initial loading I wont to run all next loader requests (that happens during soft-navigation) with react-query. Right now, I achieved that behavior with next code
I wrapped every page with such structure.
Can we have usePageData<T> hook for loading loader data from client side via react-query?
4 Replies
exotic-emeraldOP•6mo ago
@Manuel Schiller sorry for ping, but what do you think about that approach? Maybe here's a better way? Source code:
https://github.com/akhmadshin/tanstack-optimistic-navigation-starter
GitHub
GitHub - akhmadshin/tanstack-optimistic-navigation-starter
Contribute to akhmadshin/tanstack-optimistic-navigation-starter development by creating an account on GitHub.
fair-rose•6mo ago
ping again in a few days please
afk for a few days
Can we have usePageData<T> hook for loading loader data from client side via react-query?build it yourself then? or what do you need for that
exotic-emeraldOP•6mo ago
@Manuel Schiller Maybe usePageData<T> hook is a bad idea, because you need to manually set type every time you call it. The one thing that concerns me is amount of required boilerplate code in my approach. I improved it a little by creating WithErrorHandler component:
Route code:
fair-rose•6mo ago
I hope that someday we can allow users to provide their own abstractions on top of createFileRoute. but for now... that's not possible.