First time working with redux with react.
Error in edge browser.
"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers."
I searched on many posts like this. Redux store does not have a valid reducer
But I haven't find anything about this same exact issue:
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();
EDIT (Solution as mentioned by a friend bellow):
store.js Edited informations added to file store.js
import { productListReducer } from './reducers/productReducers';
const reducer = combineReducers({
productList: productListReducer,
})
productReducer.js
The professor added a file called /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
}
}