Avoiding Anonymous Functions and Objects in Render (Deep Dive)
Understand precisely when inline functions and object literals in JSX are harmless versus when they measurably hurt performance.
It's extremely common to see advice to 'never use inline arrow functions in JSX,' but this is an oversimplification — inline functions and object literals are only a performance concern when their changing reference actually defeats a downstream optimization, such as a child wrapped in React.memo or a dependency array relying on reference stability. In a component with no memoized children and no such dependency arrays, a fresh inline function every render costs a trivial allocation that's rarely worth worrying about.
It's like reusing the exact same key (a stable reference) so a lock (React.memo's comparison) recognizes it and doesn't bother rekeying the whole door each time — but if there's no lock at all on that particular door (no memoized consumer), cutting a fresh identical-looking key every time costs you nothing extra to worry about.