github statelyai/xstate @xstate/react@1.3.0

3 years ago

Minor Changes

  • 577ae023 #1915 Thanks @davidkpiano! - New hook: useInterpret(machine), which is a low-level hook that interprets the machine and returns the service:

    import { useInterpret } from '@xstate/react';
    import { someMachine } from '../path/to/someMachine';
    
    const App = () => {
      const service = useInterpret(someMachine);
    
      // ...
    };
  • 577ae023 #1915 Thanks @davidkpiano! - New hook: useSelector(actor, selector), which subscribes to actor and returns the selected state derived from selector(snapshot):

    import { useSelector } from '@xstate/react';
    
    const App = ({ someActor }) => {
      const count = useSelector(someActor, state => state.context.count);
    
      // ...
    };

Don't miss a new xstate release

NewReleases is sending notifications on new releases.