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

fix(deps): update xstate monorepo (major) #404

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

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Oct 27, 2023

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@xstate/react (source) 1.6.3 -> 4.1.3 age adoption passing confidence
xstate (source) 4.38.3 -> 5.18.2 age adoption passing confidence

Release Notes

statelyai/xstate (@​xstate/react)

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

v3.2.2

Compare Source

Patch Changes

v3.2.1

Compare Source

Patch Changes

v3.2.0

Compare Source

Minor Changes
  • #​3814 494203b3d Thanks @​Andarist! - The Provider from createActorContext(...) now accepts the options={{...}} prop that takes the same object as the second argument to the useMachine(machine, options) hook.

    These options are no longer passed as the second argument to the createActorContext(machine) function:

    -const SomeContext = createActorContext(someMachine,
    -  { actions: { ... } });
    +const SomeContext = createActorContext(someMachine);
    
    // ...
    
    -<SomeContext.Provider>
    +<SomeContext.Provider options={{ actions: { ... } }}>
    
    // ...

v3.1.2

Compare Source

Patch Changes
  • #​3804 b53856d28 Thanks @​farskid! - Interpreter options can now be specified in the second argument of createActorContext(machine, options).

v3.1.1

Compare Source

Patch Changes
  • #​3799 51d254692 Thanks @​Andarist! - Fixed an issue that caused the internally used useSyncExternalStore to warn about the computed snapshot not being cached when a not-started machine servive was passed to useActor.

v3.1.0

Compare Source

Minor Changes
  • #​3778 f12248b23 Thanks @​davidkpiano! - The createActorContext(...) helper has been introduced to make global actors easier to use with React. It outputs a React Context object with the following properties:

    • .Provider - The React Context provider
    • .useActor(...) - A hook that can be used to get the current state and send events to the actor
    • .useSelector(...) - A hook that can be used to select some derived state from the actor's state
    • .useActorRef() - A hook that can be used to get a reference to the actor that can be passed to other components

    Usage:

    import { createActorContext } from '@&#8203;xstate/react';
    import { someMachine } from './someMachine';
    
    // Create a React Context object that will interpret the machine
    const SomeContext = createActorContext(someMachine);
    
    function SomeComponent() {
      // Get the current state and `send` function
      const [state, send] = SomeContext.useActor();
    
      // Or select some derived state
      const someValue = SomeContext.useSelector((state) => state.context.someValue);
    
      // Or get a reference to the actor
      const actorRef = SomeContext.useActorRef();
    
      return (/* ... */);
    }
    
    function App() {
      return (
        <SomeContext.Provider>
          <SomeComponent />
        </SomeContext.Provider>
      );
    }

v3.0.2

Compare Source

Patch Changes
  • #​3752 4190c3fd6 Thanks @​davidkpiano! - Computing the initial state is now consistent with useMachine and useActor, avoiding stale initial state problems with nested machines

v3.0.1

Compare Source

Patch Changes
  • #​3456 131d429ab Thanks @​davidkpiano! - Add shallowEqual helper comparator function.

  • #​3500 0dfc6d92f Thanks @​Andarist! - Fixed an issue with useSelector always computing fresh snapshots internally for uninitialized services. This avoids the internal useSyncExternalStore from warning about the snapshot value not being cached properly.

v3.0.0

Compare Source

Major Changes
  • #​2939 360e85462 Thanks @​Andarist! - This package now accepts React 18 as a peer dep and the implementation has been rewritten to use use-sync-external-store package. This doesn't break compatibility with older versions of React since we are using the shim to keep compatibility with those older versions.

  • #​2939 360e85462 Thanks @​Andarist! - asEffect and asLayoutEffect action creators were removed. They were not fitting the React model that well and could lead to issues as their existence suggested that they are easy to use.

    To execute actions at those exact times you can always either just call your stuff directly from those effects or send events to the machine from those effects and execute explicit actions in response to said events.

  • #​2939 360e85462 Thanks @​Andarist! - The signatures of useMachine and useService integrating with @xstate/fsm were changed. They now only accept a single generic each (TMachine and TService respectively). This has been done to match their signatures with the related hooks that integrate with xstate itself.

Patch Changes
  • #​2939 360e85462 Thanks @​Andarist! - In v2 we have changed signatures of useMachine and useInterpret. Instead of accepting a list of generics they now only support a single generic: TMachine. This change, erroneously, was only introduced to types targeting [email protected] but the types targeting previous TS releases were still using the older signatures. This has now been fixed and users of older TS versions should now be able to leverage typegen with @xstate/react.

  • #​2939 360e85462 Thanks @​Andarist! - useMachine for xstate now correctly rerenders with the initial state when the internal service is being restarted. This might happen during Fast Refresh and now you shouldn't be able to observe this stale state that didn't match the actual state of the service.

  • #​2939 360e85462 Thanks @​Andarist! - useMachine for @xstate/fsm now starts the service in an effect. This avoids side-effects in render and improves the compatibility with StrictMode.

  • #​2939 360e85462 Thanks @​Andarist! - Implementations given to useMachine targeting @xstate/fsm are now updated in a layout effect. This avoid some stale closure problems for actions that are executed in response to events sent from layout effects.

  • Updated dependencies [360e85462, 360e85462]:

v2.0.1

Compare Source

Patch Changes
  • #​3089 862697e29 Thanks @​Andarist! - Fixed compatibility with Skypack by exporting some shared utilities from root entry of XState and consuming them directly in other packages (this avoids accessing those things using deep imports and thus it avoids creating those compatibility problems).

v2.0.0

Compare Source

Major Changes
  • #​5000 eeadb7121 Thanks @​TkDodo! - - Replace use-sync-external-store/shim with useSyncExternalStore from React.
    • Do not memoize getSnapshot in useSyncExternalStore.
    • Implement getServerSnapshot in useSyncExternalStore.
    • Expect store to always be defined in useSelector
    • Update React types to v18 and testing library to v16.

Configuration

📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday" in timezone Europe/London, 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.

👻 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.

@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from 6d2571b to d800af3 Compare October 29, 2023 03:50
@renovate renovate bot changed the title fix(deps): update dependency @xstate/react to v3 fix(deps): update xstate monorepo (major) Dec 1, 2023
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 7 times, most recently from 5a49de6 to 9511084 Compare December 8, 2023 16:51
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 4 times, most recently from b60731e to c313aed Compare December 13, 2023 20:08
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from a35fd53 to 25310c9 Compare December 24, 2023 04:42
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from e3f6948 to aaf728a Compare January 11, 2024 16:36
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from eb66293 to 0021e5f Compare January 29, 2024 16:24
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from 733a8e3 to dce0d00 Compare February 7, 2024 19:46
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from 6b6c324 to 2229291 Compare February 17, 2024 13:40
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from b32349a to 6eabf19 Compare February 27, 2024 19:52
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from 527aee7 to eb4606b Compare March 2, 2024 08:49
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from eb4606b to c60e61a Compare March 3, 2024 03:47
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from 40c48b3 to 19884fa Compare April 16, 2024 14:41
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 19884fa to 10276b0 Compare April 17, 2024 01:28
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 10276b0 to 59248be Compare April 24, 2024 21:56
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 59248be to 6b98e9c Compare May 5, 2024 00:05
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from c190a97 to 3707166 Compare June 6, 2024 16:49
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 3707166 to 7a9390f Compare June 11, 2024 13:06
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 7a9390f to 1d1dbff Compare June 22, 2024 08:40
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 1d1dbff to ca6f7a4 Compare July 13, 2024 03:20
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from 57a4775 to e75a1c2 Compare July 31, 2024 20:09
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 3 times, most recently from 0da368c to caf8f2c Compare August 15, 2024 16:18
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch 2 times, most recently from 2add65b to 0f8aab2 Compare September 6, 2024 09:09
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from 0f8aab2 to b43bb16 Compare September 8, 2024 16:03
@renovate renovate bot force-pushed the renovate/major-xstate-monorepo branch from b43bb16 to 09fa256 Compare September 21, 2024 10:05
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.

0 participants