Skip to content

Conversation

@hmnd
Copy link

@hmnd hmnd commented Apr 15, 2025

Currently, the queryClient param is optional, but this doesn't account for a query-creating function like this, where the queryClient is optional. This PR allows undefined to be returned, since undefined is already expected and supported in useQueryClient.

function createMyQuery(ctx: () => { queryClient?: QueryClient }) {
  return createQuery(() => ({
    queryKey: ['mykey'],
    queryFn: () => ({ myreturn: 'cool' }),
  }), () => ctx?.().queryClient); // queryClient returned here may be undefined 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant