I am converting a React component into Typescript (*.ts) from JS. It is giving the error below "Type expected". How would I fix this ?
const SisenseDashboard = () => {
const sisenseRef = React.useRef(null);
return (
<>
<Box
display="flex"
flexDirection="column"
alignItems="center"
marginBottom={2}
>
<h2>In-App Reporting</h2>
</Box>
<Box
ref={sisenseRef}
id="sisense-container"
className="sisense-demo"
></Box>
</>
);
};
First make sure your component file extension is .tsx
. Then you would wanna tell TypeScript that your function is a React Functional Component, with the help of FC
type from React:
import {FC} from "react";
const SisenseDashboard : FC = () => {
const sisenseRef = React.useRef(null);
return (
<>
<Box
display="flex"
flexDirection="column"
alignItems="center"
marginBottom={2}
>
<h2>In-App Reporting</h2>
</Box>
<Box
ref={sisenseRef}
id="sisense-container"
className="sisense-demo"
></Box>
</>
);
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.