You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
The child renderers of mutation, query, and subscription components should accept valid react nodes (i.e. React.ReactNode as it accepted in the 2.x branch)
Actual outcome:
Types have been redefined to JSX.Element | null. This type is unnecessarily restrictive and prevents various patterns such as:
bool && <component>, arrays of children, etc. Suggest JSX.Element | null -> React.ReactNode as the child return types for all 3 ComponentOptions
Thanks for reporting this @markkahn. This was changed to JSX.Element | null because the Query, Mutation and Subscription components were converted from being class based components to functional components. Functional components can't return ReactNode's. This is a long-standing issue, and is being tracked in:
If you or anyone else has suggestions on how we can fix this now, we're definitely all ears (and would review a PR). To fix this we could consider switching back to ReactNode as you suggested, and then wrapping our internal props.children calls in a fragment like:
but that seems kinda horrible. Regardless, we're definitely open to suggestions. The only caveats are that we don't want to switch back to class based components, and whatever changes are proposed have to work with the graphql HOC as well (which wraps the Query, Mutation and Subscription components).
I'll close this for now due to the reasons outlined in #3314 (comment), but will happily re-open if anyone has a better solution / workaround we can implement (or until #3314 (comment) is finalized).
Intended outcome:
The child renderers of mutation, query, and subscription components should accept valid react nodes (i.e.
React.ReactNode
as it accepted in the 2.x branch)Actual outcome:
Types have been redefined to
JSX.Element | null
. This type is unnecessarily restrictive and prevents various patterns such as:bool && <component>
, arrays of children, etc. SuggestJSX.Element | null
->React.ReactNode
as the child return types for all 3ComponentOptions
How to reproduce the issue:
Version
The text was updated successfully, but these errors were encountered: