The Toggle component is used to switch between two states.
Import React and the Toggle Component.
Declare the Toggle component.
0
class ExampleOne extends React.Component {
1
state = { exampleOne: true };
3
_handleChange = (e) => this.setState({ [e.target.name]: e.target.value });
8
active={this.state.exampleOne}
10
onChange={this._handleChange}
16
class ExampleTwo extends React.Component {
17
state = { exampleTwo: false };
19
_handleChange = (e) => this.setState({ [e.target.name]: e.target.value });
24
active={this.state.exampleTwo}
26
onChange={this._handleChange}