Answers for "how to reset count in react"

0

how to reset count in react

import React, {useState} from "react";function App() {const [count, setCount] = useState(0);const increment = () =>{   setCount(count+1);}const decrement = () =>{   setCount(count-1);}const reset = () =>{   setCount(0);}return (<div className="App"><button className='inc' onClick={increment}>Increment!</button><button className='dec' onClick={decrement}>Decrement!</button><button className='reset' onClick={reset}>Reset</button><h1>Current Count: {count}</h1></div>);}
Posted by: Guest on October-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language