Skip to content

Commit b946414

Browse files
committed
Snapshot can be undefined
1 parent d58e445 commit b946414

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/xstate-react/src/useSelector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export function useSelector<
3838

3939
const boundGetSnapshot = useCallback(() => actor?.getSnapshot(), [actor]);
4040
const boundSelector: typeof selector = useCallback(
41-
(snapshot: Snapshot<any>) => {
42-
if (snapshot.status === 'error') {
41+
(snapshot: Snapshot<any> | undefined) => {
42+
if (snapshot?.status === 'error') {
4343
throw snapshot.error;
4444
}
4545
return selector(snapshot as never);

0 commit comments

Comments
 (0)