Skip to content
Compare
Choose a tag to compare
@github-actions github-actions released this 19 Aug 13:16
· 19 commits to main since this release
c5a14bc

Minor Changes

  • #5354 515cc31 Thanks @davidkpiano! - Add createStoreHook(…) function for React. Creates a store hook that returns [selectedValue, store] instead of managing store instances manually.

    const useCountStore = createStoreHook({
      context: { count: 0 },
      on: {
        inc: (ctx, event: { by: number }) => ({
          ...ctx,
          count: ctx.count + event.by
        })
      }
    });
    
    // Usage
    const [count, store] = useCountStore((s) => s.context.count);
    store.trigger.inc({ by: 3 });
    
    // Usage (no selector)
    const [snapshot, store] = useCountStore();