Skip to content

fix(deps): update dependency @xstate/react to version 6.x 🌟 (major)#1503

Open
renovate[bot] wants to merge 1 commit intodevelopfrom
renovate/major-xstate
Open

fix(deps): update dependency @xstate/react to version 6.x 🌟 (major)#1503
renovate[bot] wants to merge 1 commit intodevelopfrom
renovate/major-xstate

Conversation

@renovate
Copy link
Copy Markdown
Contributor

@renovate renovate bot commented Feb 4, 2024

This PR contains the following updates:

Package Change Age Confidence
@xstate/react (source) 3.2.26.1.0 age confidence
xstate (source) 4.38.35.30.0 age confidence

Release Notes

statelyai/xstate (@​xstate/react)

v6.1.0

Compare Source

Minor Changes
  • #​5470 3e03427 Thanks @​davidkpiano! - useActor and useSelector now throw when the actor reaches an error state, allowing errors to be caught by React error boundaries.

    import { createMachine } from 'xstate';
    import { useActor } from '@​xstate/react';
    import { ErrorBoundary } from 'react-error-boundary';
    
    const machine = createMachine({
      initial: 'idle',
      states: {
        idle: {
          on: {
            fetch: 'loading'
          }
        },
        loading: {
          invoke: {
            src: fromPromise(async () => {
              throw new Error('Network error');
            }),
            onDone: 'success'
            // Without onError, the actor enters an error state
          }
        },
        success: {}
      }
    });
    
    function App() {
      return (
        <ErrorBoundary fallback={<p>Something went wrong</p>}>
          <ActorComponent />
        </ErrorBoundary>
      );
    }
    
    function ActorComponent() {
      // If the actor errors, the error will be thrown
      // and caught by the nearest error boundary
      const [snapshot, send] = useActor(machine);
    
      return <div>{snapshot.value}</div>;
    }

v6.0.0

Compare Source

Patch Changes

v5.0.5

Compare Source

Patch Changes

v5.0.4

Compare Source

Patch Changes

v5.0.3

Compare Source

Patch Changes

v5.0.2

Compare Source

Patch Changes

v5.0.1

Compare Source

Patch Changes

v5.0.0

Compare Source

Patch Changes

v4.1.3

Compare Source

Patch Changes

v4.1.2

Compare Source

Patch Changes
  • #​5055 ad38c35c37 Thanks @​SandroMaglione! - Updated types of useActor, useMachine, and useActorRef to require input when defined inside types/input.

    Previously even when input was defined inside types, useActor, useMachine, and useActorRef would not make the input required:

    const machine = setup({
      types: {
        input: {} as { value: number }
      }
    }).createMachine({});
    
    function App() {
      // Event if `input` is not defined, `useMachine` works at compile time, but risks crashing at runtime
      const _ = useMachine(machine);
      return <></>;
    }

    With this change the above code will show a type error, since input is now required:

    const machine = setup({
      types: {
        input: {} as { value: number }
      }
    }).createMachine({});
    
    function App() {
      const _ = useMachine(machine, {
        input: { value: 1 } // Now input is required at compile time!
      });
      return <></>;
    }

    This avoids runtime errors when forgetting to pass input when defined inside types.

v4.1.1

Compare Source

Patch Changes
  • #​4844 5aa6eb05c Thanks @​davidkpiano! - The useSelector(…) hook from @xstate/react is now compatible with stores from @xstate/store.

    import { createStore } from '@&#8203;xstate/store';
    import { useSelector } from '@&#8203;xstate/react';
    
    const store = createStore(
      {
        count: 0
      },
      {
        inc: {
          count: (context) => context.count + 1
        }
      }
    );
    
    function Counter() {
      // Note that this `useSelector` is from `@xstate/react`,
      // not `@xstate/store/react`
      const count = useSelector(store, (state) => state.context.count);
    
      return (
        <div>
          <button onClick={() => store.send({ type: 'inc' })}>{count}</button>
        </div>
      );
    }

v4.1.0

Compare Source

Minor Changes
  • #​4231 c2402e7bc Thanks @​davidkpiano! - The actor passed to useSelector(actor, selector) is now allowed to be undefined for an actor that may not exist yet. For actors that may be undefined, the snapshot provided to the selector function can also be undefined:

    const count = useSelector(maybeActor, (snapshot) => {
      // `snapshot` may be undefined
      return snapshot?.context.count;
    });
    
    count; // number | undefined

v4.0.3

Compare Source

Patch Changes
  • #​4695 52900a084 Thanks @​davidkpiano! - Options in createActorContext are now properly merged with provider options. Previously, provider options replaced the actor options.

    const { inspect } = createBrowserInspector();
    
    const SomeContext = createActorContext(someMachine, { inspect });
    
    // ...
    // Options are now merged:
    // { inspect: inspect, input: 10 }
    <SomeContext.Provider options={{ input: 10 }}>
      {/* ... */}
    </SomeContext.Provider>;

v4.0.2

Compare Source

Patch Changes

v4.0.1

Compare Source

Patch Changes
  • #​4497 d7f220225 Thanks @​davidkpiano! - Fix an issue where after transitions do not work in React strict mode. Delayed events (including from after transitions) should now work as expected in all React modes.

v4.0.0

Compare Source

Major Changes
  • #​3947 5fa3a0c74 Thanks @​davidkpiano! - Removed the ability to pass a factory function as argument to useMachine.

  • #​4006 42df9a536 Thanks @​davidkpiano! - useActorRef is introduced, which returns an ActorRef from actor logic:

    const actorRef = useActorRef(machine, { ... });
    const anotherActorRef = useActorRef(fromPromise(...));

    useMachine is deprecated in favor of useActor, which works with machines and any other kind of logic

    -const [state, send] = useMachine(machine);
    +const [state, send] = useActor(machine);
    const [state, send] = useActor(fromTransition(...));

    useSpawn is removed in favor of useActorRef

    -const actorRef = useSpawn(machine);
    +const actorRef = useActorRef(machine);
    
    The previous use of `useActor(actorRef)` is now replaced with just using the `actorRef` directly, and with `useSelector`:
    
    ```diff
    -const [state, send] = useActor(actorRef);
    +const state = useSelector(actorRef, s => s);
    // actorRef.send(...)
  • #​4050 fc88dc8e6 Thanks @​davidkpiano! - The options prop has been added (back) to the Context.Provider component returned from createActorContext:

    const SomeContext = createActorContext(someMachine);
    
    // ...
    
    <SomeContext.Provider options={{ input: 42 }}>
      {/* ... */}
    </SomeContext.Provider>;
  • #​4006 42df9a536 Thanks @​davidkpiano! - useActor has been removed from the created actor context, you should be able to replace its usage with MyCtx.useSelector and MyCtx.useActorRef.

  • #​4265 1153b3f9a Thanks @​davidkpiano! - FSM-related functions have been removed.

  • #​3947 5fa3a0c74 Thanks @​davidkpiano! - Implementations for machines on useMachine hooks should go directly on the machine via machine.provide(...), and are no longer allowed to be passed in as options.

    -const [state, send] = useMachine(machine, {
    -  actions: {
    -    // ...
    -  }
    -});
    +const [state, send] = useMachine(machine.provide({
    +  actions: {
    +    // ...
    +  }
    +}));
  • #​3148 7a68cbb61 Thanks @​davidkpiano! - Removed getSnapshot parameter from hooks. It is expected that the received actorRef has to have a getSnapshot method on it that can be used internally.

Minor Changes

Configuration

📅 Schedule: Branch creation - "before 3am on the first day of the month" in timezone America/New_York, Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.


Note

High Risk
Upgrades XState from v4 to v5 and @xstate/react from v3 to v6, which include major breaking API/typing changes and can break existing machine/interpreter and hook usage at runtime and compile time.

Overview
Updates state-machine dependencies by bumping xstate from 4.38.3 to 5.30.0 and @xstate/react from 3.2.2 to 6.1.0, with corresponding yarn.lock updates (including use-sync-external-store).

No application code is changed, so any required migration for XState v5 / @xstate/react v6 APIs will surface as build/test failures after the dependency upgrade.

Written by Cursor Bugbot for commit a6012e3. This will update automatically on new commits. Configure here.

@cypress-app-bot
Copy link
Copy Markdown

See the guidelines for reviewing dependency updates for info on how to review dependency update PRs.

@renovate renovate bot force-pushed the renovate/major-xstate branch from 2c5764a to 424dd37 Compare June 1, 2024 05:03
@renovate renovate bot force-pushed the renovate/major-xstate branch from 424dd37 to fdb6fdd Compare July 1, 2024 04:39
@renovate renovate bot force-pushed the renovate/major-xstate branch from fdb6fdd to 5df2a6f Compare August 1, 2024 06:49
@renovate renovate bot force-pushed the renovate/major-xstate branch from 5df2a6f to 83a262c Compare October 1, 2024 06:28
@renovate renovate bot force-pushed the renovate/major-xstate branch from 83a262c to 9276058 Compare December 1, 2024 06:41
@renovate renovate bot changed the title fix(deps): update dependency @xstate/react to version 4.x 🌟 (major) fix(deps): update dependency @xstate/react to version 5.x 🌟 (major) Dec 1, 2024
@renovate renovate bot force-pushed the renovate/major-xstate branch from 9276058 to 6e28c3d Compare March 1, 2025 06:15
@renovate renovate bot force-pushed the renovate/major-xstate branch from 6e28c3d to 4ddbdce Compare April 1, 2025 06:56
@renovate renovate bot force-pushed the renovate/major-xstate branch from 4ddbdce to 4960114 Compare June 1, 2025 05:32
@renovate renovate bot force-pushed the renovate/major-xstate branch from 4960114 to 0364efb Compare August 1, 2025 04:52
@renovate renovate bot changed the title fix(deps): update dependency @xstate/react to version 5.x 🌟 (major) fix(deps): update dependency @xstate/react to version 6.x 🌟 (major) Aug 1, 2025
@renovate renovate bot force-pushed the renovate/major-xstate branch from 0364efb to 8c8e423 Compare November 1, 2025 04:57
@renovate renovate bot force-pushed the renovate/major-xstate branch from 8c8e423 to d16093e Compare January 1, 2026 05:04
@renovate renovate bot force-pushed the renovate/major-xstate branch from d16093e to a6012e3 Compare April 1, 2026 04:35
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 8 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

"uuid": "8.3.2",
"webpack": "5",
"xstate": "4.38.3",
"xstate": "5.30.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xstate v5 removes Machine export, breaking all machines

High Severity

Upgrading xstate from v4 to v5 removes the Machine export entirely (replaced by createMachine). All 7 machine files (authMachine.ts, dataMachine.ts, drawerMachine.ts, snackbarMachine.ts, createTransactionMachine.ts, transactionFiltersMachine.ts, userOnboardingMachine.ts) import Machine from "xstate", which will cause a runtime crash on import. The application cannot start at all with this change.

Additional Locations (1)
Fix in Cursor Fix in Web

"@okta/okta-react": "^6.7.0",
"@types/detect-port": "^1.3.2",
"@xstate/react": "3.2.2",
"@xstate/react": "6.1.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useActor no longer accepts actor references in v6

High Severity

Upgrading @xstate/react from v3 to v6 changes the useActor API — it now accepts actor logic (machines), not existing actor references. Five components (AlertBar, NavBar, NavDrawer, SignInForm, SignUpForm) pass Interpreter service instances to useActor, which will crash at runtime. These should use useSelector and useActorRef instead.

Fix in Cursor Fix in Web

"uuid": "8.3.2",
"webpack": "5",
"xstate": "4.38.3",
"xstate": "5.30.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send with string events removed in xstate v5

High Severity

xstate v5 no longer supports string arguments in send() — only event objects are accepted. Multiple components call send with strings: sendDrawer("TOGGLE_DESKTOP"), sendDrawer("TOGGLE_MOBILE"), sendDrawer("OPEN_DESKTOP", payload), sendDrawer("CLOSE_MOBILE"), and sendAuth("LOGOUT") in MainLayout.tsx and NavDrawer.tsx. These calls will throw or silently fail at runtime.

Fix in Cursor Fix in Web

"uuid": "8.3.2",
"webpack": "5",
"xstate": "4.38.3",
"xstate": "5.30.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interpret and State removed, breaking auth initialization

High Severity

xstate v5 removes interpret (now createActor) and State.create (now different rehydration API). authMachine.ts uses both: interpret(authMachine) to start the global auth service and State.create(stateDefinition) to rehydrate persisted state. This will crash during module initialization, preventing the auth system from working at all.

Fix in Cursor Fix in Web

"uuid": "8.3.2",
"webpack": "5",
"xstate": "4.38.3",
"xstate": "5.30.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withConfig removed, breaking derived machine definitions

High Severity

xstate v5 renames .withConfig() to .provide(). Six machine files (bankAccountsMachine, contactsTransactionsMachine, createTransactionMachine, notificationsMachine, personalTransactionsMachine, publicTransactionsMachine) use .withConfig() with a services key (also renamed to actors in v5) to configure data-fetching behavior. All these machines will fail to initialize.

Fix in Cursor Fix in Web

"uuid": "8.3.2",
"webpack": "5",
"xstate": "4.38.3",
"xstate": "5.30.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assign signature change silently corrupts all state updates

High Severity

xstate v5 changes the assign function signature from positional (context, event) => ... to a single object ({ context, event }) => .... All 12 assign() calls across authMachine.ts, dataMachine.ts, snackbarMachine.ts, and createTransactionMachine.ts use the old positional pattern. With v5, the first parameter receives the entire { context, event } object rather than just context, and the second parameter becomes undefined, silently corrupting every state assignment.

Fix in Cursor Fix in Web

"uuid": "8.3.2",
"webpack": "5",
"xstate": "4.38.3",
"xstate": "5.30.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cond and transient "" transitions removed in v5

High Severity

xstate v5 renames cond to guard and removes transient transitions via the empty string "" event (replaced by always). drawerMachine.ts uses cond: "shouldOpenDesktop" and dataMachine.ts uses both cond: "hasData" and the "": [...] transient transition syntax. The drawer's conditional desktop open logic and the data machine's automatic routing between withData/withoutData states would silently stop working.

Fix in Cursor Fix in Web

"uuid": "8.3.2",
"webpack": "5",
"xstate": "4.38.3",
"xstate": "5.30.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoForward removed breaks child machine event forwarding

Medium Severity

xstate v5 completely removes the autoForward property from invoke configurations. createTransactionMachine.ts uses autoForward: true on the invoked transactionDataMachine to forward events like CREATE to the child data machine. Without auto-forwarding, the child machine would never receive these events, breaking the transaction creation flow.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant