T
TanStack4y ago
harsh-harlequin

How to give a placeholder value for the result of the select function and have data always defined?

Given the following useQuery
const customHook = () => useQuery(['key'], queryFN, {select: (data) => ({x: data.x, y: data.y})} )
const customHook = () => useQuery(['key'], queryFN, {select: (data) => ({x: data.x, y: data.y})} )
I want to use this custom hook in multiple places, so I want the following: be able to supply a default value for the return value of select function so that when I access the data it is never undefined. I do not want to set default value for the whole response. It is a large one
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?