skip to Main Content

ReactJs double render

When I try to refresh page it prints "1" twice. But I'm not using any useState or variable update or state change I think. Can you tell me where I'm wrong? import "./styles.css"; import React, { useState, useEffect, useRef }…

VIEW QUESTION

Reactjs – When does re-rendering actually happens?

Code: import { useState } from 'react'; export default function Counter() { const [number, setNumber] = useState(0); return ( <> <h1>{number}</h1> <button onClick={() => { setNumber(number + 1); setTimeout(()=>setNumber(number + 1),2000); setTimeout(()=>setNumber(number + 1),5000); }}>+3</button> </> ) } I went…

VIEW QUESTION
Back To Top
Search