Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
React may render a component several times, pause or discard a render before committing; side effects or mutations during render can then run extra times or leak changes from renders that never appeared.
In concurrent rendering React can start rendering an update, interrupt it for something more urgent, restart it, or throw the result away. Strict Mode also renders twice in development to surface problems. If render mutates shared objects, increments counters, writes to refs or sends analytics, those effects happen for renders the user never saw, or happen twice. Rendering must therefore be a pure calculation from props, state and context to JSX. Side effects belong in event handlers or effects, which run only after a commit, and mutable data should be copied rather than changed in place.