Skip to content

Commit

Permalink
use parseInt instead of split
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Sep 19, 2024
1 parent be5a092 commit df6c4ee
Showing 1 changed file with 1 addition and 3 deletions.
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

0 comments on commit df6c4ee

Please sign in to comment.