Utilizing useComponentContext hooks for custom components #3545
-
I was looking to make a custom value component for the const CustomValue = () => {
const selectContext = useSelectContext();
const numSelected = selectContext.selectedItems.length;
if (numSelected === 0) {
return 'Select some items...';
}
if (numSelected === selectContext.collection.size) {
return 'All selected';
}
return `${numSelected} selected`;
}; My question: is this okay to do?? Obviously, it works, but I don't see this pattern documented anywhere and I wanna make sure I'm not using library functionality exposed by accident !! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It’s absolutely okay to do that. We need to update this page https://ark-ui.com/docs/guides/component-state to include the context hook. |
Beta Was this translation helpful? Give feedback.
It’s absolutely okay to do that.
We need to update this page https://ark-ui.com/docs/guides/component-state to include the context hook.