ktongue's picture
download
raw
716 Bytes
import * as React from 'react';
/**
* Returns the ref of a React element handling differences between React 19 and older versions.
* It will throw runtime error if the element is not a valid React element.
*
* @param element React.ReactElement
* @returns React.Ref<any> | null
*/
export default function getReactElementRef(element) {
// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
if (parseInt(React.version, 10) >= 19) {
return element?.props?.ref || null;
}
// @ts-expect-error element.ref is not included in the ReactElement type
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
return element?.ref || null;
}

Xet Storage Details

Size:
716 Bytes
·
Xet hash:
766a423a048639fe4e8696b3e4015e5d49e9f44cb5d57dd823d7383aa0f4dd72

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.