github statelyai/xstate @xstate/store-react@2.1.0-alpha.1

latest release: @xstate/react@7.0.0-alpha.2
pre-release2 hours ago

Minor Changes

  • c57f80e: The useStore hook now accepts an inspect option for wiring up inspectors to component-local stores. The inspector is subscribed while the option is provided and stays stable across re-renders.

    import { useStore, useSelector } from '@xstate/store-react';
    import { createBrowserInspector } from '@statelyai/inspect';
    
    const inspector = createBrowserInspector();
    
    function Counter() {
      const store = useStore(
        {
          context: { count: 0 },
          on: {
            inc: (context) => ({ count: context.count + 1 })
          }
        },
        { inspect: inspector.inspect }
      );
      const count = useSelector(store, (s) => s.context.count);
    
      return <button onClick={() => store.send({ type: 'inc' })}>{count}</button>;
    }

Don't miss a new xstate release

NewReleases is sending notifications on new releases.