@xstate/react

  • Version 4.1.1
  • Published
  • 35.2 kB
  • 2 dependencies
  • MIT license

Install

npm i @xstate/react
yarn add @xstate/react
pnpm add @xstate/react

Overview

XState tools for React

Index

Functions

function createActorContext

createActorContext: <TLogic extends AnyActorLogic>(
actorLogic: TLogic,
actorOptions?: ActorOptions<TLogic>
) => {
useSelector: <T>(
selector: (snapshot: SnapshotFrom<TLogic>) => T,
compare?: (a: T, b: T) => boolean
) => T;
useActorRef: () => Actor<TLogic>;
Provider: (props: {
children: React.ReactNode;
options?: ActorOptions<TLogic>;
machine?: never;
logic?: TLogic;
}) => React.ReactElement<any, any>;
};

    function shallowEqual

    shallowEqual: (objA: any, objB: any) => boolean;

      function useActor

      useActor: <TLogic extends AnyActorLogic>(
      logic: TLogic,
      options?: ActorOptions<TLogic>
      ) => [SnapshotFrom<TLogic>, Actor<TLogic>['send'], Actor<TLogic>];

        function useActorRef

        useActorRef: <TLogic extends AnyActorLogic>(
        machine: TLogic,
        options?: ActorOptions<TLogic>,
        observerOrListener?: any
        ) => Actor<TLogic>;

          function useMachine

          useMachine: <TMachine extends AnyStateMachine>(
          machine: TMachine,
          options?: ActorOptions<TMachine>
          ) => [StateFrom<TMachine>, Actor<TMachine>['send'], Actor<TMachine>];
          • useActor

          function useSelector

          useSelector: <TActor extends Pick<AnyActorRef, 'subscribe' | 'getSnapshot'>, T>(
          actor: TActor,
          selector: (
          snapshot: TActor extends { getSnapshot(): infer TSnapshot }
          ? TSnapshot
          : undefined
          ) => T,
          compare?: (a: T, b: T) => boolean
          ) => T;

            Package Files (7)

            Dependencies (2)

            Dev Dependencies (10)

            Peer Dependencies (2)

            Badge

            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@xstate/react.

            • Markdown
              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@xstate/react)
            • HTML
              <a href="https://www.jsdocs.io/package/@xstate/react"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>