如何更改我的减速器中的状态,尝试将属性设置为 true/false [英] How to change my state in my reducer, trying to set a property to true/false

查看:29
本文介绍了如何更改我的减速器中的状态,尝试将属性设置为 true/false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的减速器被拆分了,其中一个我的初始状态和减速器看起来像:

My reducers are split, and in one of them my initial state and reducer looks like:

import Constants from '../constants';

const initialState = {
  fetching: true,
};

const boards = (state = initialState, action) => {
  switch (action.type) {
    case Constants.BOARDS_FETCHING:
      return state;
    default:
      return state;
  }
};

export default boards;

如何在 BOARDS_FETCHING 情况下将 fetching 属性更改为 true?

How can I change the fetching property to true in the BOARDS_FETCHING case?

更新

我的 .babelrc 看起来像:

My .babelrc looks like:

{
  "presets": ["react", "es2015"],
  "env": {
    "development": {
      "presets": ["react-hmre"]
    }
  }
}

错误:

推荐答案

您需要安装transform-object-rest-spread

 "plugins": ["transform-object-rest-spread"]

更多请查看babeljs-plugins#transform-对象休息传播

这篇关于如何更改我的减速器中的状态,尝试将属性设置为 true/false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆