Buka Corner
  • Home
  • Topics
  • Online Tools
  • Careers
  • Support Us
  • About
  • Buka
Sign in Subscribe

React

Optimizing Initial State in React with useState

Optimizing Initial State in React with useState

Saw this on X. Just saw this performance mistake in a React code review. Problem: If you invoke a function in useState's default, it's called on every render. (Not React's fault - that's how JS works). Solution: Specify a function reference instead.
Buka Corner Oct 3, 2024

Subscribe to Buka Corner

Don't miss out on the latest articles. Sign up now to get access to the library of members-only articles.
  • Sign up
Buka Corner © 2025 - All Rights Reserved.