1class App extends React.Component {
2
3state = { count: 0 }
4
5handleIncrement = () => {
6 this.setState({ count: this.state.count + 1 })
7}
8
9handleDecrement = () => {
10 this.setState({ count: this.state.count - 1 })
11}
12 render() {
13 return (
14 <div>
15 <div>
16 {this.state.count}
17 </div>
18 <button onClick={this.handleIncrement}>Increment by 1</button>
19 <button onClick={this.handleDecrement}>Decrement by 1</button>
20 </div>
21 )
22 }
23}
1class Example extends React.Component {
2 constructor(props) {
3 super(props);
4 this.state = {
5 count: 0
6 };
7 }
8
9 render() {
10 return (
11 <div>
12 <p>You clicked {this.state.count} times</p>
13 <button onClick={() => this.setState({ count: this.state.count + 1 })}>
14 Click me
15 </button>
16 </div>
17 );
18 }
19}
1import React, {Component} from 'react';
2import './App.css';
3import IconBar from './components/icon-bar';
4import Events from './components/events';
5
6class App() extends Component {
7 constructor(props) {
8 super(props)
9 this.state = {
10 mode: null
11 }
12 this.updateMode = this.updateMode.bind(this);
13 }
14
15 updateMode = (newMode) => {
16
17 this.setState({mode: newMode});
18 }
19
20
21 return (
22 <div className="App">
23 <h1 className="Title">ENAKS</h1>
24 <IconBar onUpdateMode={this.updateMode} mode={this.state.mode} />
25 <Events />
26 <div className="mainModeFrame"><p1>{this.state.mode}</p1></div>
27 </div>
28 );
29}
30
31export default App;
32Add this to your knowledge