Skip to content
Discussion options

You must be logged in to vote

if the transformation is synchronous, I wouldn't do a query for it at all, but more something like:

function useCompositeData(): UseQueryResult<string> {
  const { data: data1 } = useData1();
  const { data: data2 } = useData2();

  if (!data1 || !data2) return ""
  return getCompositeData(data1, data2)
}

if the transformation is expensive or referential identity is important, I'd stick a useMemo around it :)

In other words, what happens is useData1()'s result is in the error status

if you don't have data1, you can't compute the result. In your version, the someKey query would be in idle status because it is not enabled. You would have to check that if it is idle, you basically have no…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ericpatey
Comment options

@TkDodo
Comment options

Answer selected by ericpatey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants