Replies: 1 comment 1 reply
-
I do believe that the
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a component that can render data from multiple sources.
Each source is subtly different, but only ever contain the same type.
For example:
I'm using react-query to fetch the data. I have created a client hook for each data type.
When I render the Layer component it is dynamic from a config, so I can't manually specify which query hook is used.
It needs to be dynamic based on the config:
I'm getting Typescript errors on response.data.
It's ending up as an array of the union of possible types:
(Bus | Car)[]
instead of (as I was expecting) a union of arrays of single type:
Bus[] | Car[]
What is the "proper" way to dynamically select a query/queries client?
As in the example, I can't manually specify the query client because it's from a config (that will be supplied by an API, so that rules out using JSX inside the config).
Or is there some kind of bug from distributive unions?
I will try to create a code sandbox for this.
Beta Was this translation helpful? Give feedback.
All reactions