juliancwirko/react-s-alert

Multiple instances

Opened this issue · 3 comments

It would be great to have multiple instances of Alert to fire them independently. I didn't found anything in the docs for realizing this, i must do this with workarounds.

Use case: Global alert for all types of alerts, and a separate alert for Forms in a modal.

Feature Request:

// entry.jsx. The global alert.
import Alert from 'react-s-alert';
// ...
<div>
    <Alert/>
    <BrowserRouter>
        <Routing/>
    </BrowserRouter>
</div>
// ...
// Is fired with Alert.error('global error');
// Created component in a modal. The separate alert.
import FormAlert from "react-s-alert";
// ...
render() {
        if (this.props.errors) {
            FormAlert.error('form error');
        }
        return <div>
            <FormAlert/>
            // .. the form
        </div>;
    }

When i do this right now, all alerts are fired in both places.

Hi, I am not convinced that this should be in the scope of this package. This meant to be an alert for global messages. Also I am not sure if there will be many use cases for such approach.
Anyway, I think without a bigger rewrite it won't be possible :/ But we can leave it here. Maybe there will be some votes for such functionality.

+1 vote for this functionality. Being able to display alerts in a context-specific way (ie within a modal or separate form) would be very useful.

any news on this feature ?