Skip to content

Bug: state.matches is not a function if the state status is "error" #5436

@alita-moore

Description

@alita-moore

XState version

XState version 5

Description

currently, if I do the following

useSelector(state => state.matches("Saving"))

and the machine currently has an "error" status matches is not defined on state.

This buries the lead, the problem is something in my machine but then I'm getting a type error because react can't call this function.

Expected result

matches remains defined

Actual result

matches is not defined

Reproduction

https://stackblitz.com/edit/react-ts-playground-6bydbzce?file=index.tsx

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions