Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
useEffect(() => {
for (const { error, id, loc } of errors) {
const errorToastProps = {
icon: ErrorIcon,
message: `${ERROR_MESSAGE}\nDebug: ${id} ${loc}`,
onDismiss: remove => {
getErrorDismisser(error, handleDismiss)();
remove();
},
timeout: 15000,
type: 'error'
};
// Only add a toast for new errors. Without this condition we would
// re-add toasts when one error is removed even if there were two
// added at the same time.
const errorToastId = getToastId(errorToastProps);
if (!toasts.get(errorToastId)) {
addToast(errorToastProps);
}
}
}, [errors, handleDismiss]); // eslint-disable-line