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

[@xstate/store] Compatibility with @xstate/react's useSelector(…) hook #4844

Merged
merged 6 commits into from
Apr 17, 2024

Conversation

davidkpiano
Copy link
Member

No description provided.

Copy link

changeset-bot bot commented Apr 10, 2024

🦋 Changeset detected

Latest commit: e5b4d41

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

This PR includes changesets to release 3 packages
Name Type
@xstate/react Patch
@xstate/svelte Patch
@xstate/vue Patch

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

@@ -10,10 +10,15 @@ function defaultCompare<T>(a: T, b: T) {
return a === b;
}

export function useSelector<TActor extends AnyActorRef | undefined, T>(
export function useSelector<
TActor extends Pick<AnyActorRef, 'subscribe' | 'getSnapshot'> | undefined,
Copy link
Member

Choose a reason for hiding this comment

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

why is the previous version not compatible?

Copy link
Member Author

@davidkpiano davidkpiano Apr 10, 2024

Choose a reason for hiding this comment

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

Because Store is not fully compatible with AnyActorRef.

I tried this without this change and TypeScript complained about it

Copy link
Member

Choose a reason for hiding this comment

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

Hm, ok - lots of things are missing from this. The solution is OK 👍 I would do the same in all of the other integration packages though. @xstate/react shouldn't be the only one that becomes compatible with this

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed

@davidkpiano davidkpiano merged commit 5aa6eb0 into main Apr 17, 2024
1 check passed
@davidkpiano davidkpiano deleted the davidkpiano/store-xstate-react-compat branch April 17, 2024 00:41
@github-actions github-actions bot mentioned this pull request Apr 17, 2024
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.

2 participants