juliancwirko / react-s-alert

Alerts / Notifications for React with rich configuration options
https://www.npmjs.com/package/react-s-alert
MIT License
649 stars 75 forks source link

Multiple instances #63

Open fabpico opened 6 years ago

fabpico commented 6 years ago

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.

juliancwirko commented 6 years ago

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.

patrick-tavares commented 6 years ago

+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.

ismailkaya commented 6 years ago

any news on this feature ?