Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redux (Toolkit in this case) stays silent on all errors #65

Closed
sanjarcode opened this issue Oct 6, 2023 · 1 comment
Closed

Redux (Toolkit in this case) stays silent on all errors #65

sanjarcode opened this issue Oct 6, 2023 · 1 comment
Assignees

Comments

@sanjarcode
Copy link
Member

This is a recurring problem, happens in both web (React + ReactDOM) and native (React + ReactNative).
I'm using Redux Toolkit.

  • The problem isn't in reducers or thunks alone. Even missing import errors (in a Reducer file say) are invisible.
  • It's frustrating when this happens, especially in a mobile app.

See reduxjs/redux#1060

@sanjarcode sanjarcode self-assigned this Oct 6, 2023
@sanjarcode sanjarcode transferred this issue from another repository Jan 8, 2024
@sanjarcode
Copy link
Member Author

Fixed: add this

import { configureStore } from "@reduxjs/toolkit";
const store = configureStore({
  reducer: {
    /* reducers here */
  },

  middleware: (getDefaultMiddleware) => {
    const errorLoggingMiddleware = () => (next) => (action) => {
      if (action.type.includes("rejected")) {
        console.error("vpReduxError", action.error.message, {
          type: action.type,
          payload: action.payload,
          error: action.error,
        });
      }
      next(action);
    };

    return getDefaultMiddleware({
      serializableCheck: false,
    }).concat(errorLoggingMiddleware);
  },
});

export default store;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant