| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| @xstate_react@6.1.0 source code.tar.gz | 2026-02-26 | 2.7 MB | |
| @xstate_react@6.1.0 source code.zip | 2026-02-26 | 3.0 MB | |
| README.md | 2026-02-26 | 1.4 kB | |
| Totals: 3 Items | 5.7 MB | 0 | |
Minor Changes
-
#5470
3e03427Thanks @davidkpiano! -useActoranduseSelectornow throw when the actor reaches an error state, allowing errors to be caught by React error boundaries.```tsx import { createMachine } from 'xstate'; import { useActor } from '@xstate/react'; import { ErrorBoundary } from 'react-error-boundary';
const machine = createMachine({ initial: 'idle', states: { idle: { on: { fetch: 'loading' } }, loading: { invoke: { src: fromPromise(async () => { throw new Error('Network error'); }), onDone: 'success' // Without onError, the actor enters an error state } }, success: {} } });
function App() { return ( <ErrorBoundary fallback={\<p>Something went wrong\
}> <ActorComponent /> </ErrorBoundary> ); }function ActorComponent() { // If the actor errors, the error will be thrown // and caught by the nearest error boundary const [snapshot, send] = useActor(machine);
return
{snapshot.value}; } ```