import {forwardRef, Ref, RefAttributes, ReactElement} from 'react';

export function genericForwardRef<T, P>(
  render: (props: P, ref: Ref<T>) => Nullable<ReactElement>,
): (props: P & RefAttributes<T>) => Nullable<ReactElement> {
  return forwardRef(render as any) as (
    props: P & RefAttributes<T>,
  ) => Nullable<ReactElement>;
}
