Sorry for the consecutive questions, but how can I...
# javascript
h
Sorry for the consecutive questions, but how can I refetch the data from a loader without resetting the states of the component? Currently I use
useRevalidator().revalidate()
, but after using it my states are at the default again and it's also discouraged by the documentation to use it for data fetching purposes.
t
Is it library hook?
h
Comes from the kotlin-wrappers if that's what you mean yes.
t
Kotlin Wrappers contains multiple libraries
h
I bit the bullet and asked AI and it said it's normal that the state is lost upon revalidate and that I should use localStorage or SearchParams 🙈
useRevalidator() comes from kotlin-react-router-js
I could move the fetching from the data loader into the component of course. But I hoped I could continue to use the loader here.
t
Looks like you need loader integration with react-query to achieve required result cc @Michael Porotkin
h
Oh if it's really so much trouble I just move the loading of the data into the component. Everything I find online is using fetch inside the component.
I also found this and am currently trying it out: https://github.com/remix-run/remix/discussions/4774, buuut that's not it, it seems.
t
If you load data in component React Query highly recommended
You can check examples in Kotlin Wrappers
RQ already support refetch logic
h
We are currently using Axios because my coworker used it alot already, but I'll take a look for sure.
Especially since ReactQuery is probably full wrapped 😄
I used searchParams. Works like a charm, and still uses the data loader :3