【发布时间】:2020-04-23 10:09:11
【问题描述】:
我是 XState.js 的新手。
我想在我的上下文中使用一个简单的 ID。如何使用machine.send() 更新上下文?
const fetchMachine = Machine(
{
id: 'test',
initial: 'init',
context: {
id: '',
},
states: {
init: {
on: {
LOGIN: 'fetch',
},
},
fetch: {
on: {
LOGOUT: 'init',
},
},
}
})
const machine = interpret(fetchMachine).start()
如何将 ID 传递给上下文?
这不能解决问题:
machine.send({ type: 'LOGIN', id })
【问题讨论】:
标签: xstate