SIGN IN SIGN UP
facebook / react UNCLAIMED

The library for web and native user interfaces.

244272 0 0 JavaScript

Eagerly initialize an mutable object for instance.refs (#25696)

This micro-optimization never made sense and less so now that they're
rare.

This still initializes the class with a shared immutable object in the
constructor - which is also what createClass() does.

Then we override it during mount. This is done in case someone messes up
the initialization of the super() constructor for example, which was
more common in polyfills.

This change means that if a ref is initialized during the constructor
itself it wouldn't be lazily initialized but that's not user code that
does it, it's React so that shouldn't happen.

This makes string refs codemoddable as described in.
https://github.com/facebook/react/pull/25334
S
Sebastian Markbåge committed
d65b88d0319b37eec59c74ed9189cf5ab18b56e8
Parent: db8a3fc
Committed by GitHub <[email protected]> on 11/16/2022, 8:16:54 PM