-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 a regression that has caused machine.getInitialState(value)
to not follow always transitions correctly
#3599
Conversation
…o not follow always transitions correctly
🦋 Changeset detectedLatest commit: 64c721a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
👇 Click on the image for a new way to code review
Legend |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 64c721a:
|
@@ -1661,7 +1664,7 @@ class StateNode< | |||
return this.resolveTransition( | |||
{ | |||
configuration, | |||
entrySet: [...configuration], | |||
entrySet: configuration, |
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.
It brings back a shared reference being used for both entrySet
and for configuration
. This is somewhat dangerous but I just hope that v5 algorithm works better in this regard.
It has been like that for a long time, I've "fixed" this problem here but that accidentally caused the mentioned regression. So now instead of copying the reference, I make sure that we don't push items to the entrySet
that are already there:
https://github.com/statelyai/xstate/pull/3599/files#diff-7f553f4d4c285f1c05cced2e979c5b957d8884e39e74cc6797b32c63a0be7e7aR1015
} | ||
}); | ||
|
||
const service = interpret(machine).start(machine.getInitialState('a')); |
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.
Interestingly, this doesn't follow always transitions:
- const service = interpret(machine).start(machine.getInitialState('a'));
+ const service = interpret(machine).start('a');
I would consider this to be a bug too but it just never worked correctly and I don't think it's necessary to fix this in v4.
fixes #3544