# XState 5.31.0 - Product: XState (https://whatsnew.fyi/product/xstate) - Vendor: Stately - Date: 2026-04-27 - Version: 5.31.0 - Original notes: https://github.com/statelyai/xstate/releases/tag/xstate%405.31.0 - Permalink: https://whatsnew.fyi/product/xstate/releases/5.31.0 What's New is an index, not a publisher: every entry below links to the vendor's own release notes, which are the authoritative source. Entries are labelled where they are hand-curated sample data, pre-releases, or drawn from a secondary source such as a developer blog. Reuse: the summaries, labels and curation here are © What's New. Quote freely with attribution and a link back; wholesale republication of the corpus is not permitted — terms: https://whatsnew.fyi/terms. The vendors' own release notes remain their publishers'. --- - **added** — Add mapState(snapshot, mapper) to map a snapshot to values based on active state(s) - **added** — Add maxIterations option to configure the maximum number of microsteps allowed before throwing an infinite loop error ###### Minor Changes - [#5429](https://github.com/statelyai/xstate/pull/5429) [`9d9c1fe`](https://github.com/statelyai/xstate/commit/9d9c1fe9df43936aa6ab43a4694645a6966ace12) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Add `mapState(snapshot, mapper)` to map a snapshot to values based on active state(s). ```ts 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](https://github.com/statelyai/xstate/pull/5430) [`e543599`](https://github.com/statelyai/xstate/commit/e5435993b2dee17c0808c2997665df696865aebd) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Add `maxIterations` option to configure the maximum number of microsteps allowed before throwing an infinite loop error. The default is `Infinity` (no limit) to avoid breaking existing machines. You can configure it when creating a machine: ```ts const machine = createMachine({ // ... machine config options: { maxIterations: 1000 // set a limit to enable infinite loop detection } }); ```