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

Convert string ref props to callback props #28398

Merged
merged 2 commits into from
Feb 21, 2024

Commits on Feb 20, 2024

  1. Extract string ref logic to separate function

    Preparing to put this behind a flag. Should not affect any behavior on
    its own.
    acdlite committed Feb 20, 2024
    Configuration menu
    Copy the full SHA
    90e6a90 View commit details
    Browse the repository at this point in the history
  2. Convert string ref props to callback props

    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.
    acdlite committed Feb 20, 2024
    Configuration menu
    Copy the full SHA
    335b94c View commit details
    Browse the repository at this point in the history