diff --git a/docs/migration.mdx b/docs/migration.mdx index 7e35999e..3a95793c 100644 --- a/docs/migration.mdx +++ b/docs/migration.mdx @@ -2498,8 +2498,21 @@ import { createMachine } from 'xstate5'; If you need to use different versions of an integration package, such as `@xstate/react`, you can use a similar strategy as above, but you will need to link to the correct version of XState in the integration package. This can be done by using a script: +```json5 +// package.json +"scripts": { + "postinstall": "node scripts/xstate5-react-script.js" +}, +// We trick @xstate5/react into having a peer dependency on xstate v4, which bypasses the --legacy-peer-deps error +"overrides": { + "@xstate5/react": { + "xstate": "^4" + } +} +``` + ```bash -npm i xstate5@npm:xstate@5 @xstate5/react@npm:@xstate/react@4 --force +npm i xstate5@npm:xstate@5 @xstate5/react@npm:@xstate/react@4 ``` ```js @@ -2515,13 +2528,6 @@ fs.ensureSymlinkSync( ); ``` -```json5 -// package.json -"scripts": { - "postinstall": "node scripts/xstate5-react-script.js" -} -``` - Then, you can use the XState v5 compatible version of `@xstate/react` in your code: ```ts