Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-notification
Advanced tools
This is a component designed to provide "snackbar" notification messages. I would suggest reading the usage guidelines for snackbars.
npm install react-notification
import Notification from 'react-notification';
<Notfication
message={string}
action={string}
styles={object}
onClick={func}
/>
See here.
Name | Type | Description | Required |
---|---|---|---|
message | string | The message for the notification | true |
action | string | The name of the action, e.g., "close" or "undo" | |
styles | object | bool |
*Setting this prop to false
will disable all inline styles. This is useful if you aren't using React inline styles and would like to use CSS instead. See styles for more.
Method | Usage | |
---|---|---|
show | Notification.show() | Opens the notification. |
hide | Notification.hide() | Hides the notifciation. |
Event | Description |
---|---|
onClick | Callback function to run when the action is clicked |
This component does use basic inline CSS to style the position and visibility of the notification. You have two options for adding additional styles:
The DOM tree of the component for reference:
<div class="notficiation-bar">
<div class="notfication-bar-wrapper" onClick={this.props.onClick}>
<span class="notification-bar-message">{this.props.message}</span>
<span class="notification-bar-action">{this.props.action}</span>
</div>
</div>
To use additional inline styles, return two objects. The bar
object applies styles to the entire notification "snackbar" and the action
object applies styles to the action message. Under the hood, this uses Object.assign
to handle properly combining styles.
I would highly suggest using this method since the styles included in the component by default handle the visibility of the notification. If you remove these styles, the component won't actually show or hide itself.
getNotificationStyles() {
var bar = {
background: '#263238'
};
var action = {
color: '#FFCCBC'
};
return { bar, action };
},
render() {
return (
<div>
<Notification
ref="notification"
message={this.state.message}
action={this.state.action}
styles={this.getNotificationStyles()}
</div>
);
}
Built with care in New Orleans by Patrick Burtchaell.
Copyright 2015 Patrick Burtchaell. Licensed MIT.
FAQs
Snackbar notifications for React
The npm package react-notification receives a total of 3,090 weekly downloads. As such, react-notification popularity was classified as popular.
We found that react-notification demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.