T
TanStack2y ago
extended-salmon

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
sensitive-blue
sensitive-blue2y ago
extended-salmon
extended-salmonOP2y 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?