Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
Argument of type 'FC<ComponentType>' is not assignable to parameter of type 'ForwardRefRenderFunction<unknown, ComponentType>'

I am using react with typescript. I have two components, one is a child and the other one is a parent. I am forwarding ref to my child component and in my child component I binding my export with forwardRef but I am getting an error on export line saying: Argument of type 'FC<ComponentType>' is not assignable to parameter of type 'ForwardRefRenderFunction<unknown, ComponentType>'

Here is my code:

import { forwardRef } from 'react';
import './Label.css';

type LabelType = {
    name: string
    ref: any
}

const Label: React.FC<LabelType> = ({name, ref}) => {
  return <label className='label' ref={ref}>
</label>;
};

export default forwardRef(Label);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The documentation explains how forwardRef works: you must define the ref as the second parameter of the function component (instead of including it in the props, which is the first parameter). Then pass your function component as the first argument to forwardRef.

Here is a link to where the function signature for forwardRef is declared in the current version of the @types/react pacakge. You can inspect it to learn about how I derived the types in the following examples.

Here are two ways you can implement the instruction above to fix your current component:


Supply the appropriate generic type parameters to forwardRef (then you don't need to annotate the function component directly):

TS Playground

import {default as React, forwardRef} from 'react';
import './Label.css';

export type LabelProps = {
  name: string;
};

export const Label = forwardRef<HTMLLabelElement, LabelProps>(({name}, ref) => {
  return (<label className='label' ref={ref}>{name}</label>);
});

export default Label;

Or, annotate the function component directly:

TS Playground

import {default as React, forwardRef} from 'react';
import './Label.css';

export type LabelProps = {
  name: string;
};

const Label = forwardRef((
  {name}: LabelProps,
  ref: React.ForwardedRef<HTMLLabelElement>,
): React.ReactElement => {
  return (<label className='label' ref={ref}>{name}</label>);
});

export default Label;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!