@nex-ui/utils
Version:
Utility functions for React components.
17 lines (14 loc) • 480 B
JavaScript
import { isMemo, ForwardRef, isForwardRef } from 'react-is';
function supportRef(nodeOrComponent) {
if (typeof nodeOrComponent.type === 'string') {
return true;
}
if (isMemo(nodeOrComponent) && nodeOrComponent.type && typeof nodeOrComponent.type.type === 'object' && nodeOrComponent.type.type.$$typeof === ForwardRef) {
return true;
}
if (isForwardRef(nodeOrComponent)) {
return true;
}
return false;
}
export { supportRef };