redux store仅返回null值。在reducer处检查,reducer返回实际数据,但combinereducer不返回

时间:2018-03-21 08:58:09

标签: reactjs redux react-redux

减速/ Reduer_placeorder.js

export default function(state =[], action) {
  switch (action.type) {
    case "PLACE_ORDER":
          console.log("inside reducer")
          console.log(action.payload)//returns data that is passed
      return action.payload;


    default: 
          console.log("default")
          return state;
  }
}
  

这里返回实际有效载荷

减速/ index.js

import { combineReducers} from "redux";
import reducer_placeorder from "./Reducer_placeorder";


const rootReducer  = combineReducers({
  data:reducer_placeorder,


})
console.log("inside combine reducer")
export default rootReducer;
  

reducer_placeorder不包含数据

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import 'semantic-ui-css/semantic.min.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import { BrowserRouter } from 'react-router-dom';
import {Provider} from 'react-redux';
import {createStore} from  'redux';
import rootReducer  from './Reducers';


const store = createStore(rootReducer);
console.log("the state from store")
console.log(store.getState());
   *//returns {data: []}** not getting the passes data*
ReactDOM.render((
  <BrowserRouter><Provider store={store}><App /></Provider></BrowserRouter>
), document.getElementById('root'));
registerServiceWorker();
  

没有存储数据..只返回空数组

     

{data:[]} **   没有得到通过的状态

0 个答案:

没有答案