Md Tarek — Portfolio© 2026

Full-stack Developer

System Design — built to hold up.

dhaka → remote, worldwide

Loading experience

Md TarekTarek
React

useState Mistakes I Stopped Making

By: Md Tarek · 13 Oct 2026

Three habits fixed most of my React state bugs:

1. Derive, don't duplicate

If a value can be computed from state, compute it during render. A second useState that mirrors the first will eventually disagree with it.

2. Update from the previous value

setCount(c => c + 1) — never setCount(count + 1) inside async code.

3. One source of truth per fact

Server data, form state, and UI state are different jobs. Mixing them is where the weird bugs live.