Skip to content

@ariakit/react@0.3.0

Compare
Choose a tag to compare
@github-actions github-actions released this 06 Sep 22:58
· 1833 commits to main since this release
0945bc8

Minor Changes

  • #2714 Added support for a dynamic store prop on component stores.

    This is similar to the store prop on components, keeping both stores in sync. Now, component store hooks can support modifying the value of the store prop after the initial render. For instance:

    // props.store can change between renders now
    const checkbox = useCheckboxStore({ store: props.store });

    When the store prop changes, the object returned from the store hook will update as well. Consequently, effects and hooks that rely on the store will re-run.

    While it's unlikely, this could represent a breaking change if you're depending on the store prop in component stores to only acknowledge the first value passed to it.

  • #2783 BREAKING (This should affect very few people): The combobox state on useSelectStore has been replaced by the combobox property on the store object.

    Before:

    const combobox = useComboboxStore();
    const select = useSelectStore({ combobox });
    const hasCombobox = select.useState("combobox");

    After:

    const combobox = useComboboxStore();
    const select = useSelectStore({ combobox });
    const hasCombobox = Boolean(select.combobox);

    In the example above, select.combobox is literally the same as the combobox store. It will be defined if the combobox store is passed to useSelectStore.

  • #2783 BREAKING (This should affect very few people): The select and menu props on useComboboxStore have been removed. If you need to compose Combobox with Select or Menu, use the combobox prop on useSelectStore or useMenuStore instead.

  • #2717 The children prop as a function has been deprecated on all components. Use the render prop instead.

  • #2717 The as prop has been deprecated on all components. Use the render prop instead.

  • #2717 The backdropProps prop has been deprecated on Dialog and derived components. Use the backdrop prop instead.

  • #2745 Component stores will now throw an error if they receive another store prop in conjunction with default prop values.

Patch Changes

  • #2737 Fixed controlled component stores rendering with a stale state.

  • #2783 Component store objects now contain properties for the composed stores passed to them as props. For instance, useSelectStore({ combobox }) will return a combobox property if the combobox prop is specified.

  • #2785 Added parent and menubar properties to the menu store. These properties are automatically set when rendering nested menus or menus within a menubar.

    Now, it also supports rendering nested menus that aren't nested in the React tree. In this case, you would have to supply the parent menu store manually to the child menu store.

    These properties are also included in the returned menu store object, allowing you to verify whether the menu is nested. For instance:

    const menu = useMenuStore(props);
    const isNested = Boolean(menu.parent);
  • #2795 Updated the Menu component so the composite and typeahead props are automatically set to false when combining it with a Combobox component.

    This means you'll not need to explicitly pass composite={false} when building a Menu with Combobox component.

  • #2796 Composed store props such as useSelectStore({ combobox }) now accept null as a value.

  • Updated dependencies: @ariakit/react-core@0.3.0.