Become a member
to unlock all features

Create an egghead account to access 5000+ tutorials and resources from expert developers.

Create account

    Replace Inline Functions with String Shorthands


    It is considered best practice to use the string shorthand for actions, guards, and more when configuring an XState Machine. We do this by providing a second argument to the Machine factory function: the options object.

    On this object, we can define our actions, guards, activities, services and more. We then refer to the name of these functions with a string of the same name.

    broken: {
      entry: ['logBroken']
    // In the options object
      actions: {
        logBroken: (context, event) => { console.log('yo I am broke') }