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

[core] Improve getReactElementRef() utils #43022

Merged
merged 14 commits into from
Sep 19, 2024
Prev Previous commit
Next Next commit
update return type
  • Loading branch information
sai6855 authored and aarongarciah committed Sep 19, 2024
commit abe26e2aa554c55999dc132089079c26f71d2bf7
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import * as React from 'react';
* It will throw runtime error if the element is not a valid React element.
*
* @param element React.ReactElement
* @returns React.Ref<any> | null
* @returns React.Ref<any> | null | undefined
*/
export default function getReactElementRef(element: React.ReactElement): React.Ref<any> | null {
export default function getReactElementRef(
element: React.ReactElement,
): React.Ref<any> | null | undefined {
const reactMajorVersion = parseInt(React.version.split('.')[0], 10);

// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
Expand Down