我使用easy-peasy作为actionOn中的react应用程序的状态管理器--我需要访问另一个模型的状态,如何在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);发布于 2021-03-10 06:44:28
使onAddNote成为thunkOn而不是actionOn
https://stackoverflow.com/questions/66543590
复制相似问题