dillon1000/react

Commit

Support writing to this.refs from userspace (#28867)

Previously, the `refs` property of a class component instance was
read-only by user code — only React could write to it, and until/unless
a string ref was used, it pointed to a shared empty object that was
frozen in dev to prevent userspace mutations.

Because string refs are deprecated, we want users to be able to codemod
all their string refs to callback refs. The safest way to do this is to
output a callback ref that assigns to `this.refs`.

So to support this, we need to make `this.refs` writable by userspace.
Browse files
Changed paths3 files
First-parent comparison
M packages/react-reconciler/src/ReactFiberClassComponent.js ModifiedM packages/react-reconciler/src/__tests__/ReactFiberRefs-test.js ModifiedM packages/react/src/ReactBaseClasses.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…