xstate
xstate copied to clipboard
[v5] Improve target resolution
This PR improves target resolution:
- Targeting sibling nodes from the root is no longer valid, since the root node has no siblings
createMachine({
id: 'direction',
initial: 'left',
states: {
left: {},
right: {}
},
on: {
- LEFT_CLICK: 'left',
+ LEFT_CLICK: '.left'
}
});
- Delimiters in state node IDs resolve to the state node from the path relative to the resolved state node ID
createMachine({
// ...
on: {
SOME_EVENT: '#foo.bar' // resolves to whatever.bar
},
states: {
whatever: {
id: 'foo',
states: {
bar: {} // resolves to this state node
}
}
}
});
Closes #500
🦋 Changeset detected
Latest commit: c26249236064e46cabd110297f7c3da8e47e7d9b
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| xstate | Major |
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
Gonna test this asap - I've tried to do so a few days ago but the test output is spammed with some unrelated stuff and this made playing with it a little bit harder. Gonna take a second look on Monday or so and also I will try to clean up that test output.
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 c26249236064e46cabd110297f7c3da8e47e7d9b:
| Sandbox | Source |
|---|---|
| XState Example Template | Configuration |
| XState React Template | Configuration |