我是 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 })