State

React state equality with Object.is

React can skip unnecessary rendering work when the resulting state compares equal with Object.is.

Formal Syntax & Structure

react syntaxreact
setCount(count)

Working Example

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