{"name":"@xstate/react","version":"4.1.0","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/statelyai/xstate/tree/main/packages/xstate-react#readme","license":"MIT","main":"dist/xstate-react.cjs.js","module":"dist/xstate-react.esm.js","exports":{".":{"types":{"import":"./dist/xstate-react.cjs.mjs","default":"./dist/xstate-react.cjs.js"},"development":{"module":"./dist/xstate-react.development.esm.js","import":"./dist/xstate-react.development.cjs.mjs","default":"./dist/xstate-react.development.cjs.js"},"module":"./dist/xstate-react.esm.js","import":"./dist/xstate-react.cjs.mjs","default":"./dist/xstate-react.cjs.js"},"./package.json":"./package.json"},"imports":{"#is-development":{"development":"./src/true.ts","default":"./src/false.ts"}},"types":"dist/xstate-react.cjs.d.ts","sideEffects":false,"repository":{"type":"git","url":"git+ssh://git@github.com/statelyai/xstate.git"},"scripts":{},"bugs":{"url":"https://github.com/statelyai/xstate/issues"},"peerDependencies":{"react":"^16.8.0 || ^17.0.0 || ^18.0.0","xstate":"^5.6.2"},"peerDependenciesMeta":{"xstate":{"optional":true}},"dependencies":{"use-isomorphic-layout-effect":"^1.1.2","use-sync-external-store":"^1.0.0"},"devDependencies":{"@testing-library/react":"^13.4.0","@types/jsdom":"^12.2.3","@types/react":"^17.0.43","@types/react-dom":"^17.0.14","@types/use-sync-external-store":"^0.0.3","jsdom":"^14.0.0","jsdom-global":"^3.0.2","react":"^18.0.0","react-dom":"^18.0.0","xstate":"5.6.2"},"_id":"@xstate/react@4.1.0","gitHead":"b5d40d86aaf598ef6290e3a569d2ea75587cf3ff","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-Fh89luCwuMXIVXIua67d8pNuVgdGpqke2jHfIIL+ZjkfNh6YFtPDSwNSZZDhdNUsOW1zZYSbtUzbC8MIUyTSHQ==","shasum":"369378951e1f7f9326700f65ed02847598aad704","tarball":"http://registry-npm.ywwl.com/@xstate/react/download/@xstate/react-4.1.0.tgz","fileCount":20,"unpackedSize":35132,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDQrDJZIJeiHIvYc70UgoFHajK+U/+rmjn8J4ART5Z8GgIgO/pEbadsF2ggUlILvoPDTl+EZYRw+p5TxVSuZ+2svqw="}],"size":5895,"noattachment":false,"key":"/@xstate/react/-/@xstate/react-4.1.0.tgz"},"_npmUser":{"name":"xstate-release-bot","email":"david@stately.ai"},"directories":{},"maintainers":[{"name":"xstate-release-bot","email":"david@stately.ai"},{"name":"andarist","email":"mateuszburzynski@gmail.com"},{"name":"davidkpiano","email":"davidkpiano@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react_4.1.0_1707780937582_0.14882330602159555"},"_hasShrinkwrap":false,"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://stately.ai/docs/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\n2. Import the `useMachine` hook:\n\n```tsx\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({ type: 'TOGGLE' })}>\n      {state.value === 'inactive'\n        ? 'Click to activate'\n        : 'Active! Click to deactivate'}\n    </button>\n  );\n};\n```\n","publish_time":1707780937727,"_cnpm_publish_time":1707780937727,"dist-tags":{"alpha":"7.0.0-alpha.7","beta":"7.0.0-beta.0","latest":"6.1.0"}}