diff --git a/packages/xstate-react/src/useSelector.ts b/packages/xstate-react/src/useSelector.ts index e8f01194a4..cbdc4cb17d 100644 --- a/packages/xstate-react/src/useSelector.ts +++ b/packages/xstate-react/src/useSelector.ts @@ -38,8 +38,8 @@ export function useSelector< const boundGetSnapshot = useCallback(() => actor?.getSnapshot(), [actor]); const boundSelector: typeof selector = useCallback( - (snapshot: Snapshot) => { - if (snapshot.status === 'error') { + (snapshot: Snapshot | undefined) => { + if (snapshot?.status === 'error') { throw snapshot.error; } return selector(snapshot as never);