}>,
) => {
if (reactMajor >= 19) {
// In React 19, ref is passed as a prop, and forwardRef is often not strictly needed
const Component = (props: any) => render(props, props.ref ?? null);
Component.displayName = render.displayName ?? render.name;
return Component as React.ForwardRefExoticComponent;
}
// For React < 19, use standard React.forwardRef
return React.forwardRef(
render as React.ForwardRefRenderFunction>,
);
};
// Usage with the shim:
const MyForwardedComponent = forwardRef((props, ref) => {
// Ensure ref