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
Hey guys, I'm creating a custom ComboBox and have a question.
Basically, my component will need to have a children of type ReactNode and not the CollectionChildren<T> as expected and shown in the docs.
But since ComboBox expected the children to be of type CollectionChildren<T>, I had to do this:
I changed the expected children type from CollectionChildren<T> to ReactNode.
I created a new prop called collection of type ComboBoxPropsBase<T>["children"] (since CollectionChildren<T> is not available), which will be used in useComboBoxState hook as children;
const state = useComboBoxState({
...props,
children: collection, <----- here
defaultFilter: contains,
});
btw, my custom ComboBoxLabel and ComboBoxInput are consuming their props from a context.
Since CollectionChildren<T> type is not available by default, what do you guys think about this approach? do you know if there is another way for me to achieve the same result?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey guys, I'm creating a custom ComboBox and have a question.
Basically, my component will need to have a
children
of typeReactNode
and not theCollectionChildren<T>
as expected and shown in the docs.But since
ComboBox
expected the children to be of typeCollectionChildren<T>
, I had to do this:children
type fromCollectionChildren<T>
toReactNode
.collection
of typeComboBoxPropsBase<T>["children"]
(sinceCollectionChildren<T>
is not available), which will be used inuseComboBoxState
hook aschildren
;Here is the implementation:
btw, my custom
ComboBoxLabel
andComboBoxInput
are consuming their props from a context.Since
CollectionChildren<T>
type is not available by default, what do you guys think about this approach? do you know if there is another way for me to achieve the same result?thanks a lot in advance!
Beta Was this translation helpful? Give feedback.
All reactions