Search code snippets, questions, articles...

UseState hook in react

import React,{useState} from 'react'
const App=()=>{
  const [num,setNum]=useState(0);

  const Incre=()=>{
    setNum(num+1)
    document.title=`the  button was clicked ${num+1} times`
  }

  return(
    <>
    <button onClick={Incre}>
      click me {num}
    </button>
   
    </>
  )
}
export default App
Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet