I am new to reactjs and trying to integrate redux with my existing project.
This is my index.js
file in store
import 'rxjs'
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { reducer as formReducer } from 'redux-form'
import thunk from 'redux-thunk'
import promise from 'redux-promise-middleware'
import { createEpicMiddleware, combineEpics } from 'redux-observable'
import user, { userEpic } from './user/duck'
import app from './app'
// Bundling Epics
const rootEpic = combineEpics(
userEpic
)
// Creating Bundled Epic
const epicMiddleware = createEpicMiddleware(rootEpic)
// Define Middleware
const middleware = [
thunk,
promise(),
epicMiddleware
]
// Define Reducers
const reducers = combineReducers({
app,
user,
form: formReducer
})
// Create Store
export default createStore(reducers,window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(), applyMiddleware(...middleware))
And here is duck.js
const createUserEpic = (action$) =>
action$
.ofType(SIGNUP_CONCIERGE)
.mergeMap((action) => {
return Rx.Observable.fromPromise(api.signUpConcierge(action.payload))
.flatMap((payload) => ([{
type: SIGNUP_CONCIERGE_SUCCESS,
payload
}]))
.catch((error) => Rx.Observable.of({
type: SIGNUP_CONCIERGE_ERROR,
payload: { error }
}))
})
export const userEpic = combineEpics(
createUserEpic
)
which throws me error TypeError: action$.ofType(...).mergeMap is not a function
I have been getting this error since I updated react, react-redux, redux-observable versions.
What I am doing wrong here? Please help!!!