首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >方便-农民获得其他型号

方便-农民获得其他型号
EN

Stack Overflow用户
提问于 2021-03-09 08:51:10
回答 1查看 398关注 0票数 0

我使用easy-peasy作为actionOn中的react应用程序的状态管理器--我需要访问另一个模型的状态,如何在notes.onAddNote中访问todos.items

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-10 06:44:28

使onAddNote成为thunkOn而不是actionOn

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66543590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档