Skip to content

Commit 5440a0d

Browse files
committed
docs(no-invalid-transition-props): update docs about new transition props in xstate v5
1 parent 6043ff3 commit 5440a0d

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

docs/rules/no-invalid-transition-props.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Forbid unrecognized properties in `on`, `onDone` and `onError` transition declar
66

77
Transition declarations should not contain properties which are not recognized by XState.
88

9+
### XState v5
10+
11+
In XState v5, the following transition properties are no longer valid:
12+
13+
- `cond`: removed in favor of `guard`
14+
- `in`: removed in favor of the `stateIn` guard
15+
- `internal`: removed in favor of `reenter`
16+
917
Examples of **incorrect** code for this rule:
1018

1119
```javascript
@@ -61,7 +69,7 @@ createMachine({
6169
Examples of **correct** code for this rule:
6270

6371
```javascript
64-
// ✅ only recognized properties inside transitions
72+
// ✅ only recognized properties inside transitions (XState v4)
6573
createMachine({
6674
states: {
6775
idle: {
@@ -78,6 +86,28 @@ createMachine({
7886
},
7987
},
8088
})
89+
90+
// ✅ only recognized properties inside transitions (XState v5)
91+
createMachine({
92+
states: {
93+
idle: {
94+
on: {
95+
EVENT: {
96+
guard: () => true,
97+
target: 'active',
98+
actions: [],
99+
reenter: true,
100+
description: 'some text',
101+
},
102+
OTHER_EVENT: {
103+
// "stateIn" instead of the "in" guard
104+
guard: stateIn('otherState.ready'),
105+
target: 'active',
106+
},
107+
},
108+
},
109+
},
110+
})
81111
```
82112

83113
## Further Reading

0 commit comments

Comments
 (0)