Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redux 减速器罐';无法从动作创建者处接收数据_Redux_React Redux - Fatal编程技术网

Redux 减速器罐';无法从动作创建者处接收数据

Redux 减速器罐';无法从动作创建者处接收数据,redux,react-redux,Redux,React Redux,我的减速器有问题。我创建了一个action creator、reducer,并使用“react redux”连接将两者结合起来 当我激发我的动作时,动作创建者记录,他刚刚收到一个新数据,但reducer不记录任何东西(reducer只记录3个初始循环)。另外,我在控制台中每隔5秒显示一次store.getState(),它显示null(这是我的存储的初始状态)。你能帮我处理这个问题吗 export const UPDATE_PACKAGE_JSON = 'UPDATE_PACKAGE_JSON'

我的减速器有问题。我创建了一个action creator、reducer,并使用“react redux”连接将两者结合起来

当我激发我的动作时,动作创建者记录,他刚刚收到一个新数据,但reducer不记录任何东西(reducer只记录3个初始循环)。另外,我在控制台中每隔5秒显示一次store.getState(),它显示null(这是我的存储的初始状态)。你能帮我处理这个问题吗

export const UPDATE_PACKAGE_JSON = 'UPDATE_PACKAGE_JSON';

export function setName(name){
  console.log('Action creator just received a name', name);
  return {
    type: UPDATE_PACKAGE_JSON,
    payload: name
  }
}
容器

const mapDispatchToProps = (dispatch) =>
  bindActionCreators({ setName }, dispatch);

export default connect(null, mapDispatchToProps)(ConfigurationForm) ;
减速器

import { UPDATE_PACKAGE_JSON } from './../actions/index';

export const packageJson = function (state = null, action){
  console.log(UPDATE_PACKAGE_JSON);
  switch(action.type){
    case UPDATE_PACKAGE_JSON:
    return {...state,
      name: action.payload};
  }
  return state;
};
编辑

贮藏

import { createStore } from 'redux';

import rootReducer from './../reducers/rootReducer';

const store = createStore(rootReducer);

export default store;
减根剂

import { combineReducers } from 'redux';

import { packageJson } from './packageJson';

const rootReducer = combineReducers({
  packageJson
});

export default rootReducer;

你确定你的初始状态不应该是
{}
?我刚刚更改了它,但它没有更改主要问题:我的还原程序根本没有启动,所以它无法更改我的存储状态:(你也可以发布你的存储文件吗?存储设置是你将Redux指向你的reducer的地方。听起来Redux可能不知道你的packageJson reducer现在存在?给你