-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
🦋 Changeset detectedLatest commit: e5b4d41 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
Co-authored-by: Mateusz Burzyński <[email protected]>
No description provided.