Skip to content

Undefined not allowed as return value of queryFn since v4 #4964

Answered by TkDodo
mataslib asked this question in General
Discussion options

You must be logged in to vote

I've solved this thanks to the migration guide

That's what the migration guide is for - it tells you what you need to change when upgrading...

which is not entirely accurate. The function must not return undefined in the promise which is a pretty significant detail.

please create a PR to the docs to clarify this.

It is quite hard to find any information on this. Why it is so, etc.

The migration guide gives reasons for why it is necessary. If you return undefined from setQueryData, we opt out of the update now. This wasn't possible before, so you needed to:

const old = queryClient.setQueryData(key)
if (old) {
  queryClient.setQueryData(key, { ...old, someNewThing })
}

so effectively…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by louis-young
Comment options

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

@mataslib
Comment options

Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants