减速/ 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:[]} ** 没有得到通过的状态