{"name":"@xstate/react","version":"2.0.0-pr2674-2021926101023","description":"XState tools for React","keywords":["state","machine","statechart","scxml","state","graph","react","hook"],"author":{"name":"David Khourshid","email":"davidkpiano@gmail.com"},"homepage":"https://github.com/davidkpiano/xstate/tree/main/packages/xstate-react#readme","license":"MIT","main":"lib/index.js","module":"es/index.js","types":"lib/index.d.ts","typesVersions":{"<4.0":{"lib/index.d.ts":["index.v3.d.ts"]}},"sideEffects":false,"directories":{"lib":"lib","test":"test"},"repository":{"type":"git","url":"git+ssh://git@github.com/davidkpiano/xstate.git"},"scripts":{"clean":"rm -rf dist lib tsconfig.tsbuildinfo","build":"tsc && tsc --outDir es --module es2015 && rollup -c","test":"jest","prepublish":"npm run build && npm run test"},"bugs":{"url":"https://github.com/davidkpiano/xstate/issues"},"peerDependencies":{"@xstate/fsm":"^1.0.0","react":"^16.8.0 || ^17.0.0","xstate":"^4.27.0-pr2674-2021926101023"},"peerDependenciesMeta":{"@xstate/fsm":{"optional":true},"xstate":{"optional":true}},"dependencies":{"use-isomorphic-layout-effect":"^1.0.0","use-subscription":"^1.3.0"},"devDependencies":{"@rollup/plugin-commonjs":"^17.0.0","@rollup/plugin-node-resolve":"^11.0.1","@testing-library/react":"^8.0.9","@types/jsdom":"^12.2.3","@types/react":"^16.9.11","@types/react-dom":"^16.9.4","@xstate/fsm":"*","jest":"^26.6.3","jsdom":"^14.0.0","jsdom-global":"^3.0.2","lerna-alias":"3.0.3-0","react":"^16.12.0","react-dom":"^16.12.0","rollup":"^2.35.1","rollup-plugin-replace":"^2.2.0","rollup-plugin-terser":"^5.1.2","rollup-plugin-typescript2":"^0.30.0","ts-jest":"^26.5.6","typescript":"^4.3.5","xstate":"*"},"readme":"# @xstate/react\n\nThis package contains utilities for using [XState](https://github.com/statelyai/xstate) with [React](https://github.com/facebook/react/).\n\n- [Read the full documentation in the XState docs](https://xstate.js.org/docs/packages/xstate-react/).\n- [Read our contribution guidelines](https://github.com/statelyai/xstate/blob/main/CONTRIBUTING.md).\n\n## Quick start\n\n1. Install `xstate` and `@xstate/react`:\n\n```bash\nnpm i xstate @xstate/react\n```\n\n**Via CDN**\n\n```html\n<script src=\"https://unpkg.com/@xstate/react/dist/xstate-react.umd.min.js\"></script>\n```\n\nBy using the global variable `XStateReact`\n\nor\n\n```html\n<script src=\"https://unpkg.com/@xstate/react/dist/xstate-react-fsm.umd.min.js\"></script>\n```\n\nBy using the global variable `XStateReactFSM`\n\n2. Import the `useMachine` hook:\n\n```js\nimport { useMachine } from '@xstate/react';\nimport { createMachine } from 'xstate';\n\nconst toggleMachine = createMachine({\n  id: 'toggle',\n  initial: 'inactive',\n  states: {\n    inactive: {\n      on: { TOGGLE: 'active' }\n    },\n    active: {\n      on: { TOGGLE: 'inactive' }\n    }\n  }\n});\n\nexport const Toggler = () => {\n  const [state, send] = useMachine(toggleMachine);\n\n  return (\n    <button onClick={() => send('TOGGLE')}>\n      {state.value === 'inactive'\n        ? 'Click to activate'\n        : 'Active! Click to deactivate'}\n    </button>\n  );\n};\n```\n","readmeFilename":"README.md","_id":"@xstate/react@2.0.0-pr2674-2021926101023","_nodeVersion":"12.20.0","_npmVersion":"7.1.0","dist":{"integrity":"sha512-zxTtihzrPhDQMGnHBa5KU6r2f2NM71PIpSEQBnc6IUZF7nXhhgzFoAIz09t7oeZEnJLzpoG5YwosI673lnmoQg==","shasum":"e2af647bd243501068bd1c7991f1b7ade027dbf7","tarball":"http://registry-npm.ywwl.com/@xstate/react/download/@xstate/react-2.0.0-pr2674-2021926101023.tgz","fileCount":56,"unpackedSize":105326,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDGlBGnKOPY5wrhoqzA/qeIat47JkQjCdJd2SxGV8LBkAiAjjJPzQGy3v2c5a3pyMx6gYwNX4fFgzX5nwqdG0zxSaw=="}],"size":21686,"noattachment":false,"key":"/@xstate/react/-/@xstate/react-2.0.0-pr2674-2021926101023.tgz"},"_npmUser":{"name":"andarist","email":"mateuszburzynski@gmail.com"},"maintainers":[{"name":"andarist","email":"mateuszburzynski@gmail.com"},{"name":"davidkpiano","email":"davidkpiano@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react_2.0.0-pr2674-2021926101023_1635243317044_0.7239415398510347"},"_hasShrinkwrap":false,"publish_time":1635243317204,"_cnpm_publish_time":1635243317204,"dist-tags":{"alpha":"7.0.0-alpha.7","beta":"7.0.0-beta.0","latest":"6.1.0"}}