4.1.0 • Published 2 months ago

@xstate/react v4.1.0

Weekly downloads
103,832
License
MIT
Repository
github
Last release
2 months ago

@xstate/react

This package contains utilities for using XState with React.

Quick start

  1. Install xstate and @xstate/react:
npm i xstate @xstate/react
  1. Import the useMachine hook:
import { useMachine } from '@xstate/react';
import { createMachine } from 'xstate';

const toggleMachine = createMachine({
  id: 'toggle',
  initial: 'inactive',
  states: {
    inactive: {
      on: { TOGGLE: 'active' }
    },
    active: {
      on: { TOGGLE: 'inactive' }
    }
  }
});

export const Toggler = () => {
  const [state, send] = useMachine(toggleMachine);

  return (
    <button onClick={() => send('TOGGLE')}>
      {state.value === 'inactive'
        ? 'Click to activate'
        : 'Active! Click to deactivate'}
    </button>
  );
};
@pubngo-stack/reservation-api-browser@parksunghyun0112/react-spring-bottom-sheet-updated@storz/core@storz/react@flyteorg/console@flyteoss/console@aws-amplify/ui-react@ledgerhq/live-commonstorybook-performance-addon@hi4s/richie-educationn1k1tk-react-spring-bottom-sheetimiassist-agent@cutting/react-fetcher@cutting/use-abortds-widget@ekafyi/ekaui@react-native-norah/trotie@anima.org/db-widgt@infinitebrahmanuniverse/nolb-_xs@knapsack/app-ui@everything-registry/sub-chunk-1033@ttoss/auth@ttoss/react-auth@anchor-indexer/c7t@alteredgraphite/storybook-addon-performance@aws-amplify/ui-react-auth@aws-amplify/ui-react-core@aws-amplify/ui-react-core-auth@aws-amplify/ui-react-liveness@atrilabs/component-style-layer@atrilabs/canvas-runtimeasync-data-hooks@carousel-without-a-horse/client@catsync/re-view@connect2ic/react@connect2icmodclub/react@container-stack/mail-campaign-browser@darkblock.io/sol-widget@darkblock.io/sol-widget-r16@darkblock.io/tez-widget@darkblock.io/avax-widget@darkblock.io/darkblock-widgets@darkblock.io/eth-widget@darkblock.io/evm-widget@darkblock.io/matic-widget@cutting/react-abortable-fetch@debtcollective/union-componentcontainment@denispronin/react-spring-bottom-sheet@dexkit/darkblock-evm-widget@bitski/waas-react-sdk@bilalajanjua/react-spring-bottom-sheet@bitwebsvc/plugin-usermanage-pane@bitwebsvc/lowcode-plugin-datasource-pane@bitwebsvc/lowcode-plugin-workflow-panebrianfoody-s3o-components@breezechat/reactbyoui@ballerine/workflows-dashboard@byondrnd/byondxr-web-visualizer-ui@buildeazy-gmbh/visualizer@cafegene/utils@cardscan.ai/insurance-cardscan-react@getyoti/react-face-capture@beecomm/rsbs@wechange/frontend-coreobiiproductive-authproductive-feedpolyglot-po-clireact-native-awesome-av-playerreact-enablereact-native-rook-logger-react-nativereact-router-animation-switchreact-pin-hookreact-inline-edit-asyncreact-konva-network-graphsecsync-react-automergesecsync-react-yjszz9988zs-loginxstate-machine-webrtcxstate-viz-ycaptainxstate-routerxshapeui-react-liveness-revpayuse-secret-codevisualizer-machinesunitx-uiweb-marketing-starterymd-react-spring-bottom-sheetuse-loading-stepstina-graphql-gatewaytidus-uits-app-clizw-lowcode-plugin-datasource-panestorybook-addon-performancestorybook-xstate-wcretool-react-spring-bottom-sheetsanity-plugin-external-dam
4.1.0

2 months ago

4.0.3

2 months ago

4.0.2

3 months ago

4.0.1

4 months ago

4.0.0-beta.11

5 months ago

4.0.0-beta.10

6 months ago

4.0.0-beta.12

4 months ago

4.0.0

4 months ago

4.0.0-beta.8

9 months ago

4.0.0-beta.7

9 months ago

4.0.0-beta.9

7 months ago

4.0.0-beta.6

10 months ago

4.0.0-beta.5

10 months ago

4.0.0-beta.4

11 months ago

4.0.0-alpha.2

12 months ago

3.2.2

11 months ago

4.0.0-beta.3

12 months ago

4.0.0-alpha.1

1 year ago

4.0.0-alpha.0

2 years ago

3.2.1

1 year ago

3.2.0

1 year ago

3.0.2

1 year ago

3.0.1

2 years ago

3.0.0

2 years ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

1.6.3

2 years ago

1.6.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-rc.7

3 years ago

1.0.0-rc.6

4 years ago

1.0.0-rc.5

4 years ago

1.0.0-rc.4

4 years ago

1.0.0-rc.3

4 years ago

1.0.0-rc.2

4 years ago

1.0.0-rc.1

4 years ago

1.0.0-rc.0

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago