[XState] History state

const displayMachine = createMachine({
  initial: "hidden",
  states: {
    hidden: {
      on: {
        TURN_ON: "visible.hist",
      },
    },
    visible: {
      initial: "light",
      states: {
        light: {
          on: {
            SWITCH: {
              target: "dark",
            },
          },
        },
        dark: {
          on: {
            SWITCH: {
              target: "light",
            },
          },
        },
        hist: {
          type: "history",
        },
      },
      on: {
        TURN_OFF: "hidden",
      },
    },
  },
});
原文地址:https://www.cnblogs.com/Answer1215/p/13410417.html