1.0.2 • Published 7 years ago
imoney-react-switch v1.0.2
imoney-react-switch
Browser support
IE9+
Installation
npm i imoney-react-switch
Usage
import React from 'react';
import ReactDOM from 'react-dom';
import Switch from "imoney-react-switch";
import "imoney-react-switch/src/index.css";
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
checked: true
};
this.changeState = this.changeState.bind(this);
}
changeState(e, checked) {
e.stopPropagation();
this.setState({
checked: checked
});
}
render() {
return (
<div>
<Switch onChange={this.changeState} checked={this.state.checked}/>
</div>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('app')
);
index
changeState(e,checked,index){
e.stopPropagation();
console.log(index);
},
<Switch index="1" onChange={this.changeState} checked={true}/>
<Switch index="2" onChange={this.changeState} checked={true}/>
disable
<Switch disable={true} onChange={this.changeState} checked={true}/>