Minor Changes
-
#5429
9d9c1feThanks @davidkpiano! - AddmapState(snapshot, mapper)to map a snapshot to values based on active state(s).import { mapState } from 'xstate'; const results = mapState(snapshot, { states: { loading: { map: () => 'Loading...' }, success: { map: (snap) => snap.context.data }, error: { map: (snap) => snap.context.error.message } } }); console.log(results); // E.g. if snapshot.value === 'loading', then: // [ // { stateNode: { key: 'loading' }, result: 'Loading...' } // ]
-
#5430
e543599Thanks @davidkpiano! - AddmaxIterationsoption to configure the maximum number of microsteps allowed before throwing an infinite loop error. The default isInfinity(no limit) to avoid breaking existing machines.You can configure it when creating a machine:
const machine = createMachine({ // ... machine config options: { maxIterations: 1000 // set a limit to enable infinite loop detection } });