Unused fields not working with render-props/high-order-component
nandorojo opened this issue · 1 comments
nandorojo commented
Any thoughts on how I should handle this case?
Here's the code for Query
:
import { useQuery } from './hooks'
import { TypedDocumentNode, UseQueryArgs, AnyVariables } from 'urql'
type Options<V extends AnyVariables = AnyVariables> = Omit<UseQueryArgs<V>, 'variables' | 'query'>
export function Query<D, V extends AnyVariables = AnyVariables>({
children,
query,
variables,
requestPolicy,
context,
pause,
}: {
query: TypedDocumentNode<D, V>
children: (response: ReturnType<typeof useQuery<D, V>>) => React.ReactNode
} & (V extends {
[key: string]: never
}
? Options<V>
: Options<V> & {
variables: V
})) {
// @ts-expect-error it's fine
const result = useQuery<D, V>(query, {
variables,
requestPolicy,
context,
pause,
})
return <>{children(result)}</>
}
JoviDeCroock commented
Yes, I did not implement render props 😅 that's expected - I'm personally a bit hesitant about implementing this