State

React state snapshot

A handler uses the state values captured by its render.

Formal Syntax & Structure

react syntaxreact
const next = count + 1; setCount(next);

Working Example

Example Snippetreact
import { useState } from "react"; function Pack() { const [n,setN]=useState(0); return <button type="button" onClick={()=>{setN(n+1);console.log(n);}}>{n}</button>; }
React Reference