I have been using antD's notification
api for some time. For my newest project, I am using MUI. I need to centralize the error handling for API requests, and I am using a common Axios instance to handle that.
There are onSuccess
and onError
methods to handle the scenarios. Currently, I am using console.log to display errors or success messages. With antD I had the following option.
notification.success({
message: data.title,
description: message,
duration: 5,
});
The notification could be triggered from anywhere in the application, not necessarily from a react component. With MUI I am unable to do that. Is this possible with MUI? Can I work on a custom approach to display my error/ success messages in MUI Snackbars?
After a bit of research, I found out that there is no such implementation provided by MUI. What I am implementing now is an approach with Redux. https://www.pluralsight.com/guides/centralized-error-handing-with-react-and-redux has given a good guide.