Replies: 1 comment
-
const info = useQuery({
queryKey: ['currentWeather', place?.id],
queryFn: () => {
// do something with place
},
config: { enabled: !!place }
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! Before all, I am want to say a great job )!
I have a similar code:
`const fetchData = async (
key: string,
place: PlaceType,
) => {
/* some code */
};
const place : PlaceType | null = useSelector(/* some code*/) // place in some cases may be "null" !
const info = useQuery({
queryKey: place && ['currentWeather-${place.id}'],
variables: [place],
queryFn: fetchData
});`
And I get a type error because of the typescript infer that a null value can be passed to the function. But essentially, in the "queryKey" property, I made type guard. I'm not sure if this can be implemented, but it would be cool.
Although perhaps I did not understand how to use this right way )
Beta Was this translation helpful? Give feedback.
All reactions