Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace 'React' has no exported member 'FC'

I created a new react application by running

npx create-react-app myApp --typescript

I also updated @types/react and @types/react-dom to the latest versions, however, this error still persists when I try to declare a component's type like so

export const Header: React.FC = () => {
  return <div />;
};

How can I resolve this?

like image 689
Perplexityy Avatar asked Oct 23 '25 18:10

Perplexityy


1 Answers

I just created a new sanbox with typescript. https://codesandbox.io/s/zealous-nobel-phcd7 . Try to compare its settings with your project. You can even download it as a zip file and start a new project from it.

import * as React from "react";
import "./styles.css";

const App: React.FC = () => {
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
    </div>
  );
};

Update

I downloaded the zip file. It works for me. All I can think of is the globally installed npm versions.

You can check them with:

npm list -g --depth 0

I do not know my version hels you, but it works for me wit theese:

├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
like image 141
Peter Ambruzs Avatar answered Oct 26 '25 07:10

Peter Ambruzs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!