Skip to content

Releases: udecode/zustand-x

[email protected]

05 Feb 09:06
6991af1
Compare
Choose a tag to compare

Patch Changes

[email protected]

05 Feb 08:58
f9d500b
Compare
Choose a tag to compare

Patch Changes

[email protected]

04 Feb 22:30
d36821a
Compare
Choose a tag to compare

Major Changes

  • #100 by @zbeyens – The store hooks are now part of the public API. Previously accessible only through the store object, they are now available as standalone hooks to ensure compatibility with the new React Compiler. Added standalone hooks: useStoreValue, useStoreState, useTracked, useTrackedStore.

    We're moving away from object namespaces like use, get, set to a more functional approach where the first argument is the store state field. This includes the extended selectors and actions, where the parameters follow the first argument. This change simplifies the API and makes it more consistent with React hooks. Instead of accessing state through object properties (store.use.name()), we now use functions with the state field as the first argument (store.useValue('name')).

    Migration cases:

    // Before: store.use.name(), store.use.extendedSelector(1, 2, (a, b) => a === b)
    useStoreValue(store, 'name');
    useStoreValue(store, 'extendedSelector', 1, 2, (a, b) => a === b);
    // Equivalent to
    store.useValue('name');
    store.useValue('extendedSelector', 1, 2, (a, b) => a === b);
    
    // Before: store.useTracked.name()
    useTracked(store, 'name');
    // Equivalent to
    store.useTracked('name');
    
    // Before: store.get.name(), store.get.extendedSelector(1, 2), store.get.state()
    store.get('name');
    store.get('extendedSelector', 1, 2);
    store.get('state');
    
    // Before: store.set.name('value'), store.set.extendedAction(1, 2), store.set.state(draft => { ... })
    store.set('name', 'value');
    store.set('extendedAction', 1, 2);
    store.set('state', (draft) => {});
    
    // Before: store.extendSelectors((set, get, api) => ({ ... })). Now only api argument that you can destructure.
    store.extendSelectors(({ get }) => ({ ... }));
    
    // Before: store.extendActions((set, get, api) => ({ ... })). Now only api argument that you can destructure.
    store.extendActions(({ set }) => ({ ... }));
    • Remove mapValuesKey. This would be the equivalent:
    const stores = {
      auth: authStore,
      combobox: comboboxStore,
    };
    
    useValue(stores.auth, 'name');
    useValue(stores.combobox, 'name');

[email protected]

08 Jan 12:25
6bb9405
Compare
Choose a tag to compare

Patch Changes

[email protected]

05 Jan 19:07
fd4b351
Compare
Choose a tag to compare

Major Changes

  • #92 by @imarabinda

    • Added support for Zustand 4.5.0+.
    • mutative support. Pass mutative: true in the options.

    Migration Instructions

    Update the Store Initialization:

    1. Replace the old method of initializing the store with the new API.

      const store = createStore(
        () => ({
          name: 'zustandX',
          stars: 0,
        }),
        {
          name: 'repo',
          immer: true,
        }
      );

      or

      const store = createStore(
        {
          name: 'zustandX',
          stars: 0,
        },
        {
          name: 'repo',
          immer: true,
        }
      );
    2. Ensure to pass the configuration object with name and other options as needed.

    3. If your application relies on immer, enable it by passing immer: true in the configuration object.

      const store = createStore(
        () => ({
          name: 'zustandX',
          stars: 0,
        }),
        {
          name: 'repo',
          immer: true,
        }
      );
    4. With the new version, integrating middlewares has also changed. Here's how to upgrade your middleware usage:

      const store = createStore(
        middlewareWrapHere(() => ({
          name: 'zustandX',
          stars: 0,
        })),
        {
          name: 'repo',
          immer: true,
        }
      );

[email protected]

05 Jul 21:52
9054812
Compare
Choose a tag to compare

Patch Changes

[email protected]

18 Apr 21:15
e644c91
Compare
Choose a tag to compare

Patch Changes

  • #73 by @marbemac – Support partial state objects in the persist typings

[email protected]

29 Dec 12:32
22dab88
Compare
Choose a tag to compare

Patch Changes

[email protected]

10 Dec 16:32
8186cac
Compare
Choose a tag to compare

Patch Changes

[email protected]

08 Dec 10:40
Compare
Choose a tag to compare

Major Changes

  • #66 by @zbeyens
    • Rename @udecode/zustood package to zustand-x
    • createZustandStore: new alias for createStore