New useStoreState
hook
The useStoreState
hook is now part of the public API. Previously used internally by dynamic useState
hooks from Ariakit store objects, it is now available in the @ariakit/react
package to ensure compatibility with the new React Compiler.
The following snippets are equivalent:
const combobox = useComboboxStore();
const value = combobox.useState("value");
const combobox = useComboboxStore();
const value = useStoreState(combobox, "value");
Besides working better with the new React Compiler, useStoreState
is more flexible than store.useState
as it accepts a store that is null
or undefined
, in which case the returned value will be undefined
. This is useful when you're reading a store from a context that may not always be available:
const combobox = useComboboxContext();
const value = useStoreState(combobox, "value");
New ComboboxValue
component
A ComboboxValue
component is now available. This value component displays the current value of the combobox input without rendering any DOM elements or taking any HTML props. You can optionally pass a function as a child returning any React node based on the current value:
<ComboboxProvider>
<Combobox />
<ComboboxValue>{(value) => `Current value: ${value}`}</ComboboxValue>
</ComboboxProvider>
aria-selected
on composite items
Composite items like ComboboxItem
no longer have the aria-selected
attribute automatically set when focused. This attribute was previously used to address an old bug in Google Chrome, but it's no longer needed. Now, it's only set when the item is actually selected, such as in a select widget or a multi-selectable combobox.
This change shouldn't affect most users since the aria-selected
attribute is not part of the public API and is not recommended as a CSS selector (use [data-active-item]
instead). However, if you have snapshot tests, you may need to update them.
Other updates
- Added
userValue
prop toComboboxItemValue
. - Improved JSDocs.
- Updated dependencies:
@ariakit/react-core@0.4.9