Skip to main content

Why doesn’t updating state directly trigger a re-render?

Entry React
Quick Answer React tracks state through its setter function, not the object itself. When you do state.count = 5 directly, React never knows anything changed and doesn't schedule a re-render. You must call setState(newValue) รขโ‚ฌโ€ that's what signals React to diff the new state against the old and update the UI.

Answer

React re-renders only when the state updater function is called. Direct mutation does not notify React.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

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