# Function forwardRef

- forwardRef<T, P>(render): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>

- Lets your component expose a DOM node to a parent component using a ref.

  #### Type Parameters

  - T

    The type of the DOM node.

  - P = {}

    The props the component accepts, if any.

  #### Parameters

  - render: ForwardRefRenderFunction<T, P>

    See the ForwardRefRenderFunction.

  #### Returns ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>

  #### See

  - React Docs
  - React TypeScript Cheatsheet

  #### Example

      interface Props {
        children?: ReactNode;
        type: "submit" | "button";
      }

      export const FancyButton = forwardRef<HTMLButtonElement, Props>((props, ref) => (
        <button ref={ref} className="MyClassName" type={props.type}>
          {props.children}
        </button>
      ));

  - Defined in common/temp/node_modules/.pnpm/@types+react@18.3.3/node_modules/@types/react/index.d.ts:1599