Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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>);}
Comment

PREVIOUS NEXT
Code Example
Javascript :: ejs toggle class 
Javascript :: convert to arrow functions 
Javascript :: how to make a box in p5js 
Javascript :: usecase of async/await 
Javascript :: javascript bitset 
Javascript :: Error: ENOENT: no such file or directory, scandir 
Javascript :: turn any function into promise 
Javascript :: start withnreact 
Javascript :: A react component can only return] 
Javascript :: js pageFlip 
Javascript :: jquery override page title 
Javascript :: flatpicker js init 
Javascript :: find every character string match JavaScript 
Javascript :: react router dom link same page with different param 
Javascript :: Node_connect 
Javascript :: how to load a javascript game from react 
Javascript :: online regex generator based on string 
Javascript :: dlowlad the json fiel in react js pretty formate 
Javascript :: jest run current file vscode 
Javascript :: escaping less than great than signs in react 
Javascript :: javascript swap 
Javascript :: javascript escape comma in csv 
Javascript :: undefined ext in fn.dataTable.ext.search.push 
Javascript :: sweet form 
Javascript :: checkout code 
Javascript :: go-gitea/gitea 
Javascript :: karma get attribute 
Javascript :: react rative release 
Javascript :: Declaring Variables Shorthand javascript 
Javascript :: how to get random value from array in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =