Answers for "react generate random number"

1

react random number

function Random(props) {
        var maxNumber = 45;
        var randomNumber = Math.floor((Math.random() * maxNumber) + 1);
        return <div>{randomNumber}</div>;
      }
Posted by: Guest on June-18-2021
0

random reacths

class Button extends React.Component {

  constructor(props) {
   super(props);
   this.state = {
   random: 0
    }
   }


   render() {
   var min = 1;
   var max = 100;
   var rand =  min + (Math.random() * (max-min));
   handleClick() {
    this.setState ({this.state.random + this.rand})
   }
    return (
      <div>
       <button value="Click me!" onClick={this.handleClick.bind(this)></button>
       </div>
      );

 React.render(<Button />, document.querySelector('#container'));

  }
}
Posted by: Guest on March-19-2020

Code answers related to "react generate random number"

Code answers related to "Javascript"

Browse Popular Code Answers by Language