GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Convert string ref props to callback props by acdlite · Pull Request #28398 · react/react

Conversation

@acdlite

@acdlite acdlite commented Feb 20, 2024

Copy link
Copy Markdown
Collaborator

When enableRefAsProp is on, we should always use the props as the source of truth for refs. Not a field on the fiber.

In the case of string refs, this presents a problem, because string refs are not passed around internally as strings; they are converted to callback refs. The ref used by the reconciler is not the same as the one the user provided.

But since this is a deprecated feature anyway, what we can do is clone the props object and replace it with the internal callback ref. Then we can continue to use the props object as the source of truth.

This means the internal callback ref will leak into userspace. The receiving component will receive a callback ref even though the parent passed a string. Which is weird, but again, this is a deprecated feature, and we're only leaving it around behind a flag so that Meta can keep using string refs temporarily while they finish migrating their codebase.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
acdlite added 2 commits February 20, 2024 17:04
@acdlite
Extract string ref logic to separate function
90e6a90
Preparing to put this behind a flag. Should not affect any behavior on
its own.
@acdlite
Convert string ref props to callback props
335b94c
When enableRefAsProp is on, we should always use the props as the source
of truth for refs. Not a field on the fiber.

In the case of string refs, this presents a problem, because string refs
are not passed around internally as strings; they are converted to
callback refs. The ref used by the reconciler is not the same as the one
the user provided.

But since this is a deprecated feature anyway, what we can do is clone
the props object and replace it with the internal callback ref. Then we
can continue to use the props object as the source of truth.

This means the internal callback ref will leak into userspace. The
receiving component will receive a callback ref even though the parent
passed a string. Which is weird, but again, this is a deprecated
feature, and we're only leaving it around behind a flag so that Meta ca
keep using string refs temporarily while they finish migrating
their codebase.
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 20, 2024
@react-sizebot

react-sizebot commented Feb 20, 2024

Copy link
Copy Markdown

Comparing: cefc1c6...335b94c

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 = 176.87 kB 176.86 kB = 55.14 kB 55.14 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.02% 178.97 kB 179.00 kB +0.03% 55.77 kB 55.78 kB
facebook-www/ReactDOM-prod.classic.js = 591.94 kB 591.78 kB +0.04% 104.47 kB 104.51 kB
facebook-www/ReactDOM-prod.modern.js = 575.23 kB 575.07 kB +0.04% 101.48 kB 101.51 kB
test_utils/ReactAllWarnings.js Deleted 67.04 kB 0.00 kB Deleted 16.43 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-art/cjs/react-art.production.js +0.26% 610.32 kB 611.93 kB +0.36% 136.60 kB 137.10 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.production.js +0.26% 614.92 kB 616.53 kB +0.36% 137.90 kB 138.39 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js +0.23% 701.77 kB 703.37 kB +0.32% 153.43 kB 153.92 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js +0.22% 742.97 kB 744.57 kB +0.30% 160.85 kB 161.33 kB
test_utils/ReactAllWarnings.js Deleted 67.04 kB 0.00 kB Deleted 16.43 kB 0.00 kB

Generated by 🚫 dangerJS against 335b94c

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@acdlite
acdlite marked this pull request as ready for review February 20, 2024 22:11
@acdlite
acdlite requested a review from sebmarkbage February 20, 2024 22:11
@acdlite acdlite mentioned this pull request Feb 20, 2024
Remove string refs (behind flag) #28322
Merged
sebmarkbage
sebmarkbage approved these changes Feb 21, 2024
View reviewed changes
@acdlite
acdlite merged commit dc30644 into react:main Feb 21, 2024
github-actions Bot pushed a commit that referenced this pull request Feb 21, 2024
@acdlite
Convert string ref props to callback props (#28398)
acca79d
When enableRefAsProp is on, we should always use the props as the source
of truth for refs. Not a field on the fiber.

In the case of string refs, this presents a problem, because string refs
are not passed around internally as strings; they are converted to
callback refs. The ref used by the reconciler is not the same as the one
the user provided.

But since this is a deprecated feature anyway, what we can do is clone
the props object and replace it with the internal callback ref. Then we
can continue to use the props object as the source of truth.

This means the internal callback ref will leak into userspace. The
receiving component will receive a callback ref even though the parent
passed a string. Which is weird, but again, this is a deprecated
feature, and we're only leaving it around behind a flag so that Meta can
keep using string refs temporarily while they finish migrating their
codebase.

DiffTrain build for [dc30644](dc30644)
@huozhi huozhi mentioned this pull request Feb 26, 2024
Upgrade vendored react vercel/next.js#62549
Merged
huozhi added a commit to vercel/next.js that referenced this pull request Feb 26, 2024
@huozhi
Upgrade vendored react (#62549)
87015ac
### React upstream changes

- react/react#28438
- react/react#28436
- react/react#25954
- react/react#28434
- react/react#28433
- react/react#28432
- react/react#28415
- react/react#27903
- react/react#28430
- react/react#28424
- react/react#28400
- react/react#28422
- react/react#28423
- react/react#28412
- react/react#28418
- react/react#28421
- react/react#28417
- react/react#28399
- react/react#28408
- react/react#28350
- react/react#28387
- react/react#28403
- react/react#28384
- react/react#28409
- react/react#28398
- react/react#28405
- react/react#28328
- react/react#28402
- react/react#28386
- react/react#28388
- react/react#28379
- react/react#28383
- react/react#28390
- react/react#28389
- react/react#28382
- react/react#28348



Closes NEXT-2600
acdlite added a commit that referenced this pull request Feb 27, 2024
@acdlite
Remove string refs (behind flag) (#28322)
c979895
Depends on:

- #28398

---

This removes string refs, which has been deprecated in Strict Mode for
seven years.

I've left them behind a flag for Meta, but in open source this fully
removes the feature.
github-actions Bot pushed a commit that referenced this pull request Feb 27, 2024
@acdlite
Remove string refs (behind flag) (#28322)
d76cf6b
Depends on:

- #28398

---

This removes string refs, which has been deprecated in Strict Mode for
seven years.

I've left them behind a flag for Meta, but in open source this fully
removes the feature.

DiffTrain build for [c979895](c979895)
@ztanner ztanner mentioned this pull request Mar 19, 2024
(backport) Update React from 60a927d04 to 14898b6a9 vercel/next.js#63442
Closed
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
@acdlite @AndyPengc12
Convert string ref props to callback props (react#28398)
3802ef6
When enableRefAsProp is on, we should always use the props as the source
of truth for refs. Not a field on the fiber.

In the case of string refs, this presents a problem, because string refs
are not passed around internally as strings; they are converted to
callback refs. The ref used by the reconciler is not the same as the one
the user provided.

But since this is a deprecated feature anyway, what we can do is clone
the props object and replace it with the internal callback ref. Then we
can continue to use the props object as the source of truth.

This means the internal callback ref will leak into userspace. The
receiving component will receive a callback ref even though the parent
passed a string. Which is weird, but again, this is a deprecated
feature, and we're only leaving it around behind a flag so that Meta can
keep using string refs temporarily while they finish migrating their
codebase.
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
@acdlite @AndyPengc12
Remove string refs (behind flag) (react#28322)
f0546bf
Depends on:

- react#28398

---

This removes string refs, which has been deprecated in Strict Mode for
seven years.

I've left them behind a flag for Meta, but in open source this fully
removes the feature.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
@acdlite
Convert string ref props to callback props (#28398)
3513824
When enableRefAsProp is on, we should always use the props as the source
of truth for refs. Not a field on the fiber.

In the case of string refs, this presents a problem, because string refs
are not passed around internally as strings; they are converted to
callback refs. The ref used by the reconciler is not the same as the one
the user provided.

But since this is a deprecated feature anyway, what we can do is clone
the props object and replace it with the internal callback ref. Then we
can continue to use the props object as the source of truth.

This means the internal callback ref will leak into userspace. The
receiving component will receive a callback ref even though the parent
passed a string. Which is weird, but again, this is a deprecated
feature, and we're only leaving it around behind a flag so that Meta can
keep using string refs temporarily while they finish migrating their
codebase.

DiffTrain build for commit dc30644.
Akshato07 pushed a commit to Akshato07/-Luffy that referenced this pull request Feb 20, 2025
@acdlite
Remove string refs (behind flag) (#28322)
161ee24
Depends on:

- react/react#28398

---

This removes string refs, which has been deprecated in Strict Mode for
seven years.

I've left them behind a flag for Meta, but in open source this fully
removes the feature.

DiffTrain build for commit react/react@c979895.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@acdlite
Convert string ref props to callback props (react#28398)
1ce6d94
When enableRefAsProp is on, we should always use the props as the source
of truth for refs. Not a field on the fiber.

In the case of string refs, this presents a problem, because string refs
are not passed around internally as strings; they are converted to
callback refs. The ref used by the reconciler is not the same as the one
the user provided.

But since this is a deprecated feature anyway, what we can do is clone
the props object and replace it with the internal callback ref. Then we
can continue to use the props object as the source of truth.

This means the internal callback ref will leak into userspace. The
receiving component will receive a callback ref even though the parent
passed a string. Which is weird, but again, this is a deprecated
feature, and we're only leaving it around behind a flag so that Meta can
keep using string refs temporarily while they finish migrating their
codebase.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@acdlite
Remove string refs (behind flag) (react#28322)
d0b736a
Depends on:

- react#28398

---

This removes string refs, which has been deprecated in Strict Mode for
seven years.

I've left them behind a flag for Meta, but in open source this fully
removes the feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@sebmarkbage sebmarkbage sebmarkbage approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@acdlite @react-sizebot @sebmarkbage @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.