Description
In the Guards documentation section, the 3rd argument has misleading descriptions:
https://xstate.js.org/docs/guides/guards.html#guards-condition-functions
The condMeta object includes the following properties:
- cond - the original condition object
- state - the resolved machine state, after transition
- _event - the SCXML event
https://xstate.js.org/docs/guides/guards.html#serializing-guards
guardMeta - an object containing meta data about the guard and transition, including:
- cond - the original cond object
- state - the current machine state, before transition
Is the state property the machine state after or before transition?
Or is this the different between nonserialized and serialized guard functions?
Whichever the answer is I believe the documentation should clarify.
Nice catch. I believe the docs are wrong here.
I think a stateGuard always has the current machine state. Only when the guard evaluates to true, the transition can be taken. Therefore, the state in a guard should always be the one before the transition.
Would gladly accept a PR for this one!