学无先后,达者为师

网站首页 前端文档 正文

redux.js:275 Uncaught Error: Actions must be plain objects. Instead, the actual type was: ‘function‘

作者:谢小妞 更新时间: 2022-02-28 前端文档

redux.js:275 Uncaught Error: Actions must be plain objects. Instead, the actual type was: ‘function‘

import store from './store'
import { AUGMENT, SUBTRACT } from './antistop'

export const augment = (data) => ({ type: AUGMENT, data })

export const subtract = (data) => ({ type: SUBTRACT, data })

// 异步定义的方法 action
// store直接接收对象 异步传的是一个方法是不对的
export const settienbgj = (data, varf) => {
     return () => {
          setTimeout(() => {
               store.dispatch(augment(data))
          }, varf)
     }
}

store直接接收对象 异步传的是一个方法是不对的
需要安装 redux-thunk

npm add redux-thunk

在这里插入图片描述

原文链接:https://blog.csdn.net/weixin_45663264/article/details/122059814

栏目分类
最近更新