We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3682da5 commit 6252045Copy full SHA for 6252045
ReactButtonToggleCC.js
@@ -0,0 +1,27 @@
1
+import React, { useState } from 'react';
2
+import ReactDOM from 'react-dom';
3
+
4
+class Toggle extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+ this.handleClick = this.handleClick.bind(this);
8
+ this.state = { isON: true }
9
+ }
10
11
+ handleClick() {
12
+ this.setState({ isON: !this.state.isON });
13
14
15
+ render() {
16
+ const { isON } = this.state;
17
+ let isActive = isON ? 'ON' : 'OFF';
18
+ return (
19
+ <button onClick={this.handleClick}>{isActive}</button>
20
+ );
21
22
+}
23
24
+ReactDOM.render(
25
+ <Toggle />,
26
+ document.getElementById('root')
27
+);
0 commit comments