Skip to content

Files

Latest commit

27c2b58 · Jun 23, 2020

History

History

04

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jun 23, 2020
Jun 23, 2020
Jun 23, 2020
Jun 23, 2020
Jun 23, 2020

Exercise 04 - Actions

Goals

Execute an action with XState that set's the data-point attribute of #box to wherever it was clicked on the mousedown event.

Tips

  • Start with the previous state machine in Exercise 03.
  • Use an inline function first for the transition action. Remember that action functions take two arguments - context and event.

Extra Credit

  • Separate the action into its own named function.
  • Configure the action in the machine in the options.actions property in the second argument to createMachine(def, options):
createMachine(
  {
    // ...
  },
  {
    actions: {
      // ...
    },
  }
);