I have started with react was experimenting something. but I am continuously getting error sating that "Uncaught TypeError: (0 , _reactRedux.combineReducers) is not a function
" here is my demo configuration file
import React from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware,compose } from 'redux'
import { Provider } from 'react-redux'
import createLogger from 'redux-logger'
import thunk from 'redux-thunk'
import App from './containers/App'
import promise from "redux-promise-middleware"
import logger from "redux-logger"
import reducer from "./reducers"
const middleware = applyMiddleware(promise(), thunk, logger())
const store= createStore(reducer,middleware)
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
)
this index.js of reducers import { combineReducers } from "react-redux" import users from "./UserReducer"
export default combineReducers({
users,
}
)
User reducer.js
export default function reducer(state={users:[]},action){
// console.log("inside reducer")
switch(action.type){
case "FETCH_USERS":{
console.log("inside reducer",{...state})
return {...state,users:action.payload}
}
}
}
combineReducers is provided by the 'redux' package, not 'react-redux'.
So:
import { combineReducers } from 'redux'
should fix it
How about change this
export default combineReducers({
users,
}
)
To this
import { combineReducers } from 'redux'
import users from './users'
const someApp = combineReducers({
users
})
export default someApp
And import it in app.js
or index.js
where you put your route. Just like this.
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { createStore } from 'redux'
import someApp from './reducers'
import App from './components/App'
let store = createStore(someApp)
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With