signoz/frontend/src/hooks/useErrorNotification.ts
Rajat Dabade b9409820cc
refactor: remove the dependency of services from redux (#2998)
* refactor: remove the dependency of services using redux

* refactor: seperated columns and unit test case

* refactor: move the constant to other file

* refactor: updated test case

* refactor: removed the duplicate enum

* fix: removed the inline function

* fix: removed the inline function

* refactor: removed the magic string

* fix: change the name from matrics to metrics

* fix: one on one mapping of props

* refactor: created a hook to getting services through api call

* fix: linter error

* refactor: renamed the file according to functionality

* refactor: renamed more file according to functionality

* refactor: removed unwanted interfaces and renamed files

* refactor: separated types

* refactor: shifted mock data and completed review changes

* chore: updated test cases

* refactor: added useEffect in errornotification

* chore: updated service test

* chore: shifted loading to table level

* chore: updated test cases

---------

Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
2023-07-25 20:45:12 +05:30

18 lines
410 B
TypeScript

import { AxiosError } from 'axios';
import { useEffect } from 'react';
import { useNotifications } from './useNotifications';
const useErrorNotification = (error: AxiosError | null): void => {
const { notifications } = useNotifications();
useEffect(() => {
if (error) {
notifications.error({
message: error.message,
});
}
}, [error, notifications]);
};
export default useErrorNotification;