Skip to content

[Bug]: React 19, Accessing element.ref is no longer supported #31534

Closed

Description

Library

React Components / v9 (@fluentui/react-components)

System Info

N/A

Are you reporting Accessibility issue?

None

Reproduction

N/A

Bug Description

Actual Behavior

Accessing element.ref is deprecated: https://react.dev/blog/2024/04/25/react-19-upgrade-guide#deprecated-element-ref

We have various places where we work with elements directly and access refs:



We should check all locations and:

  • modify getTriggerChild to return a ref i.e. const [child, childRef] = getTriggerChild()
  • or add a separate helper

A compat helper will decide what accessor to use, a naive example:

function getElementRef(element: any) {
  return (React as any)
    // React 19 has new internals
    .__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE
    ? element.props.ref
    : element.ref;
}

POC https://stackblitz.com/edit/vitejs-vite-5nghj2?file=package.json,src%2FApp.tsx&terminal=dev

Logs

No response

Requested priority

High

Products/sites affected

No response

Are you willing to submit a PR to fix?

no

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Activity

  1. added
    Resolution: Soft Close
    on Feb 10, 2025
  2. microsoft-github-policy-service commented on Feb 10, 2025

    @microsoft-github-policy-service

    This issue has not had activity for over 180 days! We're adding Soft close label and will close it soon for house-keeping purposes.
    Still require assistance? Please add comment - "keep open".

  3. Foorack commented on Feb 10, 2025

    @Foorack

    keep open

  4. ahqsoftwares commented on Feb 10, 2025

    @ahqsoftwares

    Any status on this issue?

  5. removed
    Resolution: Soft Close
    on Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions