reducer 分开写不起作用这是为什么啊啊啊啊



  • import {
    combineReducers
    } from 'redux';
    import splash from './splash';
    import drawer from './drawer';

    const rootReducer = combineReducers({
    splash,
    drawer
    });

    export default rootReducer;



  • store部分代码拿出来看看
    你的这部分代码是正确的



  • @chezhe import {
    createStore,
    applyMiddleware
    } from 'redux';
    import thunkMiddleware from 'redux-thunk';
    import createLogger from 'redux-logger';
    import rootReducer from '../reducers/index';
    const loggerMiddleware = createLogger();

    const createStoreWithMiddleware = applyMiddleware(thunkMiddleware, loggerMiddleware)(createStore);

    export default function configureStore(initialState) {
    const store = createStoreWithMiddleware(rootReducer, initialState);

    return store;
    

    }



  • 蹲坑一时爽
    function mapStateToProps(state) {

    console.log(state);
    const {
        newsdetail
    } = state
    return {
        newsdetail
    };
    

    }

    finally ,debug 查出state里的成员和reducers里的名称一致的,什么鬼,mapStateToProps的时候const要写一致啊


登录后回复