我們不允許尋求書(shū)籍、工具、軟件庫(kù)等推薦的問(wèn)題。你可以編輯這個(gè)問(wèn)題,以便用事實(shí)和引用來(lái)回答。
您可以使用react-notifications庫(kù)向您的web應(yīng)用程序添加通知。這是文檔和npm包的鏈接。 下面是一些檢查通知的示例代碼。
import React from 'react';
import {
NotificationContainer,
NotificationManager,
} from 'react-notifications';
class Notifications extends React.Component {
createNotification = (type) => {
return () => {
switch (type) {
case 'info':
NotificationManager.info('Info message');
break;
case 'success':
NotificationManager.success('Success message', 'Title here');
break;
case 'warning':
NotificationManager.warning(
'Warning message',
'Close after 3000ms',
3000
);
break;
case 'error':
NotificationManager.error('Error message', 'Click me!', 5000, () => {
alert('callback');
});
break;
}
};
};
render() {
return (
<div>
<button
className="btn btn-info"
onClick={this.createNotification('info')}
>
Info
</button>
<hr />
<button
className="btn btn-success"
onClick={this.createNotification('success')}
>
Success
</button>
<hr />
<button
className="btn btn-warning"
onClick={this.createNotification('warning')}
>
Warning
</button>
<hr />
<button
className="btn btn-danger"
onClick={this.createNotification('error')}
>
Error
</button>
<NotificationContainer />
</div>
);
}
}
export default Notifications;