You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Alerts are currently being handled via the useAlert custom hook. This approach requires to define the alert object from any component and consume it as a JSX element. I.e.,
importuseAlertsfrom"src/hooks/useAlerts";constMyComponent=()=>{constalerts=useAlerts();constsetAlertMessage=()=>{alerts.addAlert("success-alert",// name: string"Everything went fine!",// title: string"success"// variant: AlertVariant);};(...)return(<><alerts.ManagedAlerts/>(...)</>);};exportdefaultMyComponent;
The problem with this approach is that it lacks consistency when a new Alert is defined in "short-live" components (e.g., Modal dialogs that are destroyed when closed. In some cases, they don't even disappear). Besides, a new Alert object must be defined every time to use the addAlert function, which is inefficient.
Ideally, the alert state would be handled globally (via dispatching redux action), thus allowing a single element to display alerts from multiple sources.
The text was updated successfully, but these errors were encountered:
carma12
changed the title
Adjust useAlerts to be retrieved using Redux
Adjust Alerts to be retrieved using Redux
Mar 8, 2024
The Alerts are currently being handled via the
useAlert
custom hook. This approach requires to define thealert
object from any component and consume it as a JSX element. I.e.,The problem with this approach is that it lacks consistency when a new Alert is defined in "short-live" components (e.g., Modal dialogs that are destroyed when closed. In some cases, they don't even disappear). Besides, a new Alert object must be defined every time to use the
addAlert
function, which is inefficient.Ideally, the alert state would be handled globally (via dispatching redux action), thus allowing a single element to display alerts from multiple sources.
The text was updated successfully, but these errors were encountered: