React Rendering Gotcha: Uncontrolled Identity Changes

Everything inside your component is recreated on every render. Most developers know this. But very few actually feel the impact of it. I didn’t… until it started affecting performance in a real feature. When React re-renders a component, it doesn’t “update” it. It runs the entire function again. That means: • Variables are re-created   • Functions get new references   • Objects & arrays become new instances  Even if the UI looks exactly the same. At first, this feels harmless. Until you see something like this 👇 A small state change in parent →   Triggers multiple child re-renders →   No visible bug → but UI becomes slower  The problem wasn’t React. It was this: const data = { value: count }; const handleClick = () => doSomething(); Looks fine. But on every render: - data is a new object   - handleClick is a new function  And React sees: “New reference = something changed” The real issue is not re-rendering. It’s uncontrolled identity changes. That’s when these stopped being “optimizations” for me: • React.memo   • useCallback   • useMemo  And became tools to control behavior. The shift that matters: Don’t ask: Why did it re-render? Ask: What changed by reference? Once you understand this, you stop writing React casually. And start writing it intentionally. Curious — what’s one time React rendering surprised you? #ReactJS #Frontend #JavaScript #WebDevelopment #SoftwareEngineering #DevLife

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories