Skip to content

Commit

Permalink
Snapshot can be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Sep 12, 2024
1 parent 3306ef2 commit b3c1769
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/xstate-react/src/useSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export function useSelector<

const boundGetSnapshot = useCallback(() => actor?.getSnapshot(), [actor]);
const boundSelector: typeof selector = useCallback(
(snapshot: Snapshot<any>) => {
if (snapshot.status === 'error') {
(snapshot: Snapshot<any> | undefined) => {
if (snapshot?.status === 'error') {
throw snapshot.error;
}
return selector(snapshot as never);
Expand Down

0 comments on commit b3c1769

Please sign in to comment.