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

Fixed issue with useService returning an initial state for services in their final states #1504

Merged
merged 4 commits into from
Oct 1, 2020

Conversation

Andarist
Copy link
Member

fixes #1503

@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2020

🦋 Changeset detected

Latest commit: f8e15ae

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

This PR includes changesets to release 5 packages
Name Type
xstate Patch
@xstate/react 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

packages/core/src/interpreter.ts Outdated Show resolved Hide resolved
@@ -17,7 +17,7 @@ export function fromService<TContext, TEvent extends EventObject>(
send: service.send.bind(service),
subscribe: service.subscribe.bind(service),
stop: service.stop!,
current: service.initialized ? service.state : machine.initialState,
current: service._status !== 0 ? service.state : machine.initialState,
Copy link
Member

Choose a reason for hiding this comment

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

Should probably import InterpreterStatus here

Copy link
Member Author

Choose a reason for hiding this comment

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

couldn't do this right now, because the older XState versions don't have such export - I've exported InterpreterStatus from the xstate package though and added a comment here that we should migrate to it whenever we decide to release a new major of @xstate/react

@davidkpiano davidkpiano merged commit f79314d into master Oct 1, 2020
@davidkpiano davidkpiano deleted the fix/use-service-final-states branch October 1, 2020 23:38
This was referenced Oct 1, 2020
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.

@xstate/react state is wrong in useService when the machine stops or reaches a final state
2 participants