Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
react-toggle-switch
Advanced tools
A simple iOS inspired toggle switch.
npm install --save react-toggle-switch
https://patrickgrimard.io/react-toggle-switch/
import React, {Component} from 'react';
import {render} from 'react-dom';
import Switch from 'react-toggle-switch'
class MyComponent extends Component {
constructor(props) {
super(props);
this.state = {
switched: false
};
}
toggleSwitch = () => {
this.setState(prevState => {
return {
switched: !prevState.switched
};
});
};
render() {
return (
<div>
{/* Basic Switch */}
<Switch onClick={this.toggleSwitch} on={this.state.switched}/>
{/* With children */}
<Switch onClick={this.toggleSwitch} on={this.state.switched}>
<i class="some-icon"/>
</Switch>
{/* Disabled */}
<Switch onClick={this.toggleSwitch} on={this.state.switched} enabled={false}/>
{/* Custom classnames */}
<Switch onClick={this.toggleSwitch} on={this.state.switched} className='other-class'/>
</div>
);
}
}
export default MyComponent;
Please take note that as of version 3.0.0, a Switch
no longer maintains an internal state. Using this component
requires that you pass both an onClick
method and an on
value to set the current state of the Switch
. More
details about why this was changed can be found here.
onClick
- Function handler to be called any time the switch is clicked.on
- Sets the switch on or off.enabled
- If set to false
, the switch cannot be toggled. Default is true
.className
- Optional CSS classes for the root element.@import "node_modules/react-toggle-switch/dist/css/switch.min.css"
FAQs
Simple iOS inspired toggle switch
The npm package react-toggle-switch receives a total of 3,158 weekly downloads. As such, react-toggle-switch popularity was classified as popular.
We found that react-toggle-switch 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
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.