Skip to content

Commit

Permalink
Add notistack for query error
Browse files Browse the repository at this point in the history
  • Loading branch information
devleejb committed Jan 23, 2024
1 parent 75097d8 commit 5ed1efc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
37 changes: 37 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"color": "^4.2.3",
"lib0": "^0.2.88",
"moment": "^2.30.1",
"notistack": "^2.0.8",
"randomcolor": "^0.6.2",
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0",
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/hooks/useErrorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { useSnackbar } from "notistack";
import { useCallback } from "react";

export function useErrorHandler() {
const handleError = useCallback((error: Error) => {}, []);
const { enqueueSnackbar } = useSnackbar();
const handleError = useCallback((error: Error) => {
enqueueSnackbar(error.message || "Something went wrong...", { variant: "error" });
}, []);

Check warning on line 8 in frontend/src/hooks/useErrorHandler.ts

View workflow job for this annotation

GitHub Actions / Check the source code (18.x)

React Hook useCallback has a missing dependency: 'enqueueSnackbar'. Either include it or remove the dependency array

return handleError;
}
5 changes: 4 additions & 1 deletion frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import { store } from "./store/store";
import { Provider } from "react-redux";
import { PersistGate } from "redux-persist/integration/react";
import { persistStore } from "redux-persist";
import { SnackbarProvider } from "notistack";

const persistor = persistStore(store);

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<App />
<SnackbarProvider maxSnack={3}>
<App />
</SnackbarProvider>
</PersistGate>
</Provider>
</React.StrictMode>
Expand Down

0 comments on commit 5ed1efc

Please sign in to comment.