使用导出默认存储时,Redux存储没有有效的缩减器

使用导出默认存储时,Redux存储没有有效的缩减器,redux,Redux,第一次使用react使用redux 边缘浏览器中出现错误 “存储没有有效的缩减器。请确保传递给CombineReducer的参数是其值为缩减器的对象。” 我搜索了很多这样的帖子。 但我还没有找到关于这个问题的任何信息: store.js import { createStore, combineReducers, applyMiddleware } from 'redux'; import thunk from 'redux-thunk' import { compos

第一次使用react使用redux

边缘浏览器中出现错误

“存储没有有效的缩减器。请确保传递给CombineReducer的参数是其值为缩减器的对象。”

我搜索了很多这样的帖子。

但我还没有找到关于这个问题的任何信息:

store.js

    import { createStore, combineReducers, applyMiddleware } from 'redux';
    import thunk from 'redux-thunk'
    import { composeWithDevTools } from 'redux-devtools-extension'
    
    const reducer = combineReducers({})
  
    const initialState = {}
     
    const middleware = [thunk]
    
    const store = createStore(reducer, initialState,
          composeWithDevTools(applyMiddleware(...middleware)))
    
    export default store
index.js

    import React from 'react';
    import ReactDOM from 'react-dom';
    import { Provider } from 'react-redux'
    import store from './store'
    import './index.css';
    import './bootstrap.min.css'
    import App from './App';
    import reportWebVitals from './reportWebVitals';
    
    ReactDOM.render(
      <Provider store={store}>
        <App />
      </Provider>,
      document.getElementById('root')
    );
    
    // If you want to start measuring performance in your app, pass a function
    // to log results (for example: reportWebVitals(console.log))
    // or send to an analytics endpoint. Learn more.
    reportWebVitals();
productReducer.js

export const productListReducer = (state = { products: [] }, action ) => {
    switch(action.type) {
        case 'PRODUCT_LIST_REQUEST':
            return {loading:true, products:[]};
        case 'PRODUCT_LIST_SUCCESS':            
            return {loading:false, products:action.payload};
        case 'PRODUCT_LIST_FAIL':
            return {loading:false, error:action.payload};
        default:
            return state
    }
}
教授添加了一个名为/reducers/productReducer.js的文件

export const productListReducer = (state = { products: [] }, action ) => {
    switch(action.type) {
        case 'PRODUCT_LIST_REQUEST':
            return {loading:true, products:[]};
        case 'PRODUCT_LIST_SUCCESS':            
            return {loading:false, products:action.payload};
        case 'PRODUCT_LIST_FAIL':
            return {loading:false, error:action.payload};
        default:
            return state
    }
}

问题是您没有传递任何要由“组合减速器”组合的减速器。只要你没有通过任何减速器,就没有人听你的动作

例:
import myReducer from./reducers'const reducer=combineReducer({myReducer:myReducer})


然后你可以把这个传给你的商店。

我正在做一个课程和当前视频,代码是一样的。我将做下一个视频,看看如何填充它。我想你是对的,我的朋友,这很有效!你完全正确。它在下一个课程视频中填充,教授用productList填充了这个参数,现在工作正常!