react-notification-system
react-notification-system copied to clipboard
Add maximum number of notification shown
It is good to have option that
<NotificationSystem max=3 ref="notificationSystem" />
My current simulation of it is
if (this._notificationSystem.state.notifications.length > 3) {
let allUIds = this._notificationSystem.state.notifications.map(
notification => notification.uid
);
let keepUIds = this._notificationSystem.state.notifications
.slice(3)
.map(notification => notification.uid);
_.difference(allUIds, keepUIds).map(uid =>
this._notificationSystem.removeNotification(uid)
);
}
@chungchi300 While this is a good idea, few thing are to be considered.
Setting an upper notification limit is fine.
However if the limit is hit there are few ways to handle this:
- don't add new notifications,
- replace least recent notification with new one.
Perhaps we can consider which one is the best approach to support and what are the use cases (yours is one of them).
I am also looking for something similar although my ideal approach would be to collapse all notifications into a notification carousel container.
If there are arguments against using this pattern I'd be interested in hearing them.