random reacths

Solutions on MaxInterview for random reacths by the best coders in the world

showing results for - "random reacths"
Carmen
29 Oct 2020
1class Button extends React.Component {
2
3  constructor(props) {
4   super(props);
5   this.state = {
6   random: 0
7    }
8   }
9
10
11   render() {
12   var min = 1;
13   var max = 100;
14   var rand =  min + (Math.random() * (max-min));
15   handleClick() {
16    this.setState ({this.state.random + this.rand})
17   }
18    return (
19      <div>
20       <button value="Click me!" onClick={this.handleClick.bind(this)></button>
21       </div>
22      );
23
24 React.render(<Button />, document.querySelector('#container'));
25
26  }
27}