Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'FC' does not exist on type 'typeof React

Tags:

react-tsx

Version "typescript": "^3.9.5" "@types/react": "^16.9.36", Property 'FC' does not exist on type 'typeof React I'm all out of ideas.

In .tsx files that contain react, I am continually getting the errors:

Property 'FC' does not exist on type 'typeof React'.

and

I get this in every .tsx file that contains react.

I know it has to be some combination of my Visual Studio configuration and the project config.

Anyone have any ideas for what to check that would only affect some workstations? I can provide as much as I can without giving away company info.

like image 455
Chetan Jain Avatar asked Oct 27 '22 21:10

Chetan Jain


1 Answers

Encountered this problem due to syntax error on my end. If you are migrating from React native to the typescript one, check whether you converted the following properly:

function Counter(props: {initialCount: string}) {
    ...
}

to

interface CounterProps {
    initialCount: string
}

const Counter : React.FC<CounterProps> = (props: CounterProps) => {
    ...
}

If this does not solve the problem then check whether the React that is getting imported, from where is it getting imported?

FC can be found in @types/react in node_modules/@types/react/index.d.ts/React.

like image 92
Sarthak Agrawal Avatar answered Jan 02 '23 20:01

Sarthak Agrawal