Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support writing to this.refs from userspace #28867

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Apr 18, 2024

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.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 18, 2024
@react-sizebot
Copy link

react-sizebot commented Apr 18, 2024

Comparing: 0061ca6...7e688c6

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 168.91 kB 168.90 kB = 52.94 kB 52.93 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 170.57 kB 170.56 kB = 53.44 kB 53.43 kB
facebook-www/ReactDOM-prod.classic.js = 590.83 kB 590.81 kB = 103.91 kB 103.90 kB
facebook-www/ReactDOM-prod.modern.js = 566.65 kB 566.62 kB = 100.10 kB 100.09 kB
test_utils/ReactAllWarnings.js Deleted 64.44 kB 0.00 kB Deleted 16.10 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react/cjs/react.production.js = 37.16 kB 37.04 kB = 10.42 kB 10.41 kB
oss-stable/react/cjs/react.production.js = 35.51 kB 35.39 kB = 10.07 kB 10.06 kB
oss-stable-semver/react/cjs/react.production.js = 35.48 kB 35.36 kB = 10.04 kB 10.03 kB
test_utils/ReactAllWarnings.js Deleted 64.44 kB 0.00 kB Deleted 16.10 kB 0.00 kB

Generated by 🚫 dangerJS against 7e688c6

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.
Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet

@acdlite acdlite merged commit ea24427 into facebook:main Apr 18, 2024
38 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 18, 2024
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.

DiffTrain build for [ea24427](ea24427)
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
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.

DiffTrain build for commit ea24427.
kassens added a commit that referenced this pull request Apr 19, 2024
kassens added a commit that referenced this pull request Apr 19, 2024
Reverts #28867

It broke some tests, reverting until we figure out why to avoid having
too much delay in the sync.
github-actions bot pushed a commit that referenced this pull request Apr 19, 2024
Reverts #28867

It broke some tests, reverting until we figure out why to avoid having
too much delay in the sync.

DiffTrain build for commit f5ce642.
github-actions bot pushed a commit that referenced this pull request Apr 19, 2024
Reverts #28867

It broke some tests, reverting until we figure out why to avoid having
too much delay in the sync.

DiffTrain build for [f5ce642](f5ce642)
acdlite added a commit that referenced this pull request Apr 23, 2024
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.
acdlite added a commit that referenced this pull request Apr 23, 2024
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.
acdlite added a commit that referenced this pull request Apr 23, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants