T
TanStack3y ago
correct-apricot

refetching from child component with typescript?

What is the best way to refetch a query from a child component when using typescript? Do you pass refetch from the parent, then set up the interface props like this? Or is there a fundmental react-query method that I'm missing?
import {QueryObserverResult} from "react-query";

interface FlashCardAppProps {
decks: Deck[],
refetch: ()=>Promise<QueryObserverResult<unknown, unknown>>
}
import {QueryObserverResult} from "react-query";

interface FlashCardAppProps {
decks: Deck[],
refetch: ()=>Promise<QueryObserverResult<unknown, unknown>>
}
2 Replies
provincial-silver
provincial-silver3y ago
correct-apricot
correct-apricotOP3y ago
So the fetch query is like use query except if it already exists there’s no additional trip to the server ?

Did you find this page helpful?