Lint and compiler
set-state-in-render
An unconditional setter during render can cause repeated rendering. Compute derived output directly or update state in response to an event. Narrow conditional adjustment patterns require separate review.
Formal Syntax & Structure
react syntaxreact
react-hooks/set-state-in-renderWorking Example
Example Snippetreact
import {useState} from 'react';export default function App(){const [n,setN]=useState(0);return <button onClick={()=>setN(v=>v+1)}>Count {n}</button>}