Unable to read property type undefined (reaction-router-reduction)

I am trying to redirect to the page after exiting. However, every time I log out, it successfully redirects the page. However, I still got the error

Unable to read the 'type' property from undefined

Further studies using the โ€œPause on Excepted Exceptionsโ€ are related to the reaction-router-reduction .

enter image description here

So the line store.dispatch(push('/signin'))in the code below causes the problem. If I switch to .map(() => ({ type: 'NOT_EXIST' }));, there will be no problems.

What could be the reason for this? Thanks

actions /auth.action.js

export const signOutSucceedEpic = (action$, store) =>
  action$
    .ofType(SIGN_OUT_SUCCEED)
    .map(() => store.dispatch(push('/signin')));  // <- this line causes the issue

actions /index.js

import { combineEpics } from 'redux-observable';

export default combineEpics(
  // ...
  signOutSucceedEpic
);

index.js

import { Provider } from 'react-redux';
import { Route } from 'react-router-dom';
import { ConnectedRouter, routerMiddleware, push } from 'react-router-redux';
import createHistory from 'history/createBrowserHistory';
import rootEpic from './actions/index';

const history = createHistory();
const routeMiddleware = routerMiddleware(history);
const epicMiddleware = createEpicMiddleware(rootEpic);

export const store = createStore(
  rootReducer,
  persistedState,
  composeWithDevTools(
    applyMiddleware(
      epicMiddleware,
      routeMiddleware
    )
  )
);

ReactDOM.render(
  <Provider store={store}>
    <ConnectedRouter history={history}>
      <div>
        <Route path="/signin" component={SignIn} />
        <Route exact path="/" component={Home} />
      </div>
    </ConnectedRouter>
  </Provider>,
  document.getElementById('root')
);
+4
1

, store.dispatch map, store.dispatch(), , undefined , . response-router-redux undefined, , type, .

, , store.dispatch - . epic , reducex-, store.dispatch push():

export const signOutSucceedEpic = (action$, store) =>
  action$
    .ofType(SIGN_OUT_SUCCEED)
    .map(() => push('/signin'));
+1

Source: https://habr.com/ru/post/1682589/


All Articles