statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
27.21k stars 1.26k forks source link

[@xstate/store] Add `shallowEqual` #5085

Closed davidkpiano closed 2 months ago

davidkpiano commented 2 months ago

The shallowEqual comparator has been added for selector comparison:

import { shallowEqual } from '@xstate/store';
import { useSelector } from '@xstate/store/react';

import { store } from './store';

function MyComponent() {
  const state = useSelector(
    store,
    (s) => {
      return s.items.filter(/* ... */);
    },
    shallowEqual
  );

  // ...
}
changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: a7f4fd434121fa5a83d17060dc081a1f9d1d57c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------- | ----- | | @xstate/store | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR