What is lazy initialization of state in useState?

Mid React

Answer

useState(() => ...) runs the initializer only once during the first render, avoiding repeated expensive computations on every render.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice