
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
mx-react-toaster
Advanced tools
A simple react toaster component This is a corrected fork of react-alert.
$ npm install mx-react-toaster
It expects external react
, react-dom
and react-addons-css-transition-group
.
To use it, you have to import the AlertContainer
component, like this:
import React from 'react';
import AlertContainer from 'mx-react-toaster';
export default class App extends React.Component {
constructor(props){
super(props);
this.alertOptions = {
offset: 14,
position: 'bottom left',
theme: 'dark',
time: 5000,
transition: 'scale'
};
}
showAlert(){
this.msg.show('Some text or component', {
time: 2000,
type: 'success',
icon: <img src="path/to/some/img/32x32.png" />
});
}
render(){
return(
<div>
<AlertContainer ref={a => this.msg = a} {...this.alertOptions} />
<button onClick={this.showAlert.bind(this)}>Show Alert</button>
</div>
);
}
}
The AlertContainer
component accepts the following options:
{
//defaults
offset: 14, //the offset of the alert from the page border, can be any number
position: 'bottom left', //the position of the alert, can be [bottom left, bottom right, top left, top right]
theme: 'dark', //the color theme of the alert, can be [dark, light, color]
time: 5000, //the time in miliseconds to the alert close itself, use 0 to prevent auto close (apply to all alerts)
transition: 'scale' //the transition animation, can be [scale, fade]
}
When you call the show
method, you can include the following options as a second parameter:
{
time: 0, //the time in miliseconds to the alert close itself, use 0 to prevent auto close (apply to this alert only), default is 5000
type: 'info', //the alert type, can be [info, success, error], default is info
icon: <img src="path/to/some/img/32x32.png" /> //the icon to show in the alert, if none is given the default of each type will be showed
}
Once you have the reference of the AlertContainer
you can call the following methods:
//show an alert
this.msg.show('Some message or component');
//show an info alert
this.msg.info('Some info message or component');
//show a success alert
this.msg.success('Some success message or component');
//show an error alert
this.msg.error('Some error message or component');
//removes all alerts from the page
this.msg.removeAll();
You can also use a React Component to show a alert message, like this:
//show an alert with a React Component as content
this.msg.show(<AComponent aProp="some message" />);
FAQs
A simple react toaster component
We found that mx-react-toaster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.