Get the alert to destroy itself

In one of the exercises with a button, opening an alert and at the same time make the latter dismissible, the dismiss-functionality is passed along as a parameter.

I understand the concept, but won’t it make more sense to keep the dismiss-function inside the alert-component, assuming that all this behavior is common on all alerts, so that App.tsx shows the alert, while Alert.tsx removes itself?

As I see it; if we have multiple components that share the same, dynamic alert-functionality, it could potentially cause a lot of extra code and errors.

Any thoughts on this?

Makes sense to me to have the overall command and control of the various components handled by a “master” App.

What if something were to happen elsewhere in your App that meant clearing of some Alerts? If the App wasn’t in control of all this, how would the Alert component(s) know to dismiss themselves?