【发布时间】:2021-03-09 08:51:10
【问题描述】:
我正在使用easy-peasy 作为 React 应用程序的状态管理器
在actionOn 中我需要访问另一个模型的状态,如何访问notes.onAddNote 中的todos.items?
import { createStore, StoreProvider, action, actionOn } from 'easy-peasy';
const todos= {
items: [],
addTodo: action((state, text) => {
state.items.push(text)
})
};
const notes = {
items: [],
addNote: action((state, text) => {
state.items.push(text)
}),
onAddNote: actionOn(
(actions, storeActions) => storeActions.notes.addNote,
(state, target) => {
// HOW TO READ todos items
}
),
};
const models = {
todos,
notes
};
const store = createStore(models);
【问题讨论】:
标签: javascript reactjs easy-peasy