Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update xstate monorepo to v5 (major) #476

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Apr 3, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@xstate/react (source) 3.2.2 -> 5.0.1 age adoption passing confidence
xstate (source) 4.38.0 -> 5.19.1 age adoption passing confidence

Release Notes

statelyai/xstate (@​xstate/react)

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 - At any time (no schedule defined), Automerge - At any time (no schedule defined).

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

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


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

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

Copy link

netlify bot commented Apr 3, 2024

Deploy Preview for superstore-redwood-stripe ready!

Name Link
🔨 Latest commit c331df4
🔍 Latest deploy log https://app.netlify.com/sites/superstore-redwood-stripe/deploys/676b28a0a99cce000889070e
😎 Deploy Preview https://deploy-preview-476--superstore-redwood-stripe.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 4 times, most recently from 99de6d0 to 4b4d5df Compare April 9, 2024 15:48
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from b2154b6 to 6e7a9e4 Compare April 17, 2024 01:45
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 4 times, most recently from 0ba61ab to 49c91a4 Compare April 27, 2024 03:24
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 49c91a4 to cbe2be6 Compare May 5, 2024 00:32
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from cbe2be6 to 11d7556 Compare June 1, 2024 16:36
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 4 times, most recently from 016fa17 to bf4f0f8 Compare June 18, 2024 11:41
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from 2a410a2 to db65755 Compare June 22, 2024 12:45
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from 5ca27e2 to 123852a Compare July 5, 2024 08:31
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 4 times, most recently from 20b2fed to c4ee3eb Compare July 16, 2024 19:56
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from c4ee3eb to bd6a722 Compare July 26, 2024 14:35
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from 77b1cdf to b0258ac Compare July 31, 2024 19:56
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from efcbeaf to 6c7e772 Compare August 15, 2024 17:39
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 4 times, most recently from 881766a to c19f668 Compare August 30, 2024 16:49
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from c19f668 to e531b78 Compare September 6, 2024 11:10
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from e531b78 to 780f433 Compare September 21, 2024 07:56
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 780f433 to b06be3a Compare November 12, 2024 15:23
@renovate renovate bot changed the title Update xstate monorepo (major) Update xstate monorepo to v5 (major) Nov 12, 2024
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from 9f1109d to b2292c6 Compare November 18, 2024 16:51
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 4 times, most recently from 24b736c to 5c1b0ae Compare December 5, 2024 06:09
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from 500850e to b4fec35 Compare December 17, 2024 07:24
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from b4fec35 to 435589e Compare December 24, 2024 01:28
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 435589e to c331df4 Compare December 24, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant