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>
</>
);
};

Make sure your component file extension is .tsx and not .ts. This should resolve your issue. Addinonnaly, you could tell TypeScript that your function is a React Functional Component, for example, with the help of the 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>
</>
);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With