[XState] History state

Posted answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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",
      },
    },
  },
});

 

以上是关于[XState] History state的主要内容,如果未能解决你的问题,请参考以下文章

[XState] Track Infinite States with with XState Context

[XState] Invoking a Promise for Asynchronous State Transitions in XState

[XState] Multiple Simultaneous States with Parallel States

如何获得分层 xstate 机的初始状态?

在 XState FSM 中使用外部数据

XState.js 如何将上下文发送到机器?