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
use parseInt instead of split
  • Loading branch information
sai6855 authored and aarongarciah committed Sep 19, 2024
commit b84c85d34ea6d0495ca3703f3fb0312f7f387415
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import * as React from 'react';
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
if (reactMajorVersion >= 19) {
if (parseInt(React.version, 10) >= 19) {
return element.props?.ref;
}
// @ts-expect-error element.ref is not included in the ReactElement type
Expand Down
Loading