DEV Community

Discussion on: React Hooks: Implementation of useState

Collapse
 
punitkmryh_93 profile image
Punitkumar Y Harsoor
randomNumber = () => {              
    this.setState((prevState)=>{
      {
//random number to 10 
          n: (Math.floor(Math.random() * 10))
     }
  })
}

Since its an asynchronous function you may face error in future.