Skip to content

Commit 086e6a3

Browse files
committed
fix: undefined exceptions
Despite the types saying these things can't be undefined, there are error reports of them being undefined
1 parent d8d42fb commit 086e6a3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/xstateTree.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export function XstateTreeView({ interpreter }: XStateTreeViewProps) {
202202
// This is needed because the inState function needs to be recreated if the
203203
// current state the machine is in changes. But _only_ then
204204
// eslint-disable-next-line react-hooks/exhaustive-deps
205-
[current.value]
205+
[current?.value]
206206
);
207207
const selectorsProxy = useConstant(() => {
208208
return new Proxy(
@@ -294,7 +294,7 @@ export function recursivelySend<
294294
) as unknown as Interpreter<any, any, any, any>[];
295295

296296
// If the service can't handle the event, don't send it
297-
if (service.state.nextEvents.includes((event as any).type)) {
297+
if (service.getSnapshot()?.nextEvents.includes((event as any).type)) {
298298
try {
299299
service.send(event as any);
300300
} catch (e) {

0 commit comments

Comments
 (0)