I am trying to convert Reactjs Component to Typescript Component
Tabs Component is shown below
<Tabs>
<Tab label="one"></Tab>
<Tab label="two"></Tab>
</Tabs>
import React, { useState } from "react";
const Tabs = ({ children }) => {
const [activeTab, setActiveTab] = useState(children[0].props.label);
};
I get typescript error like props is not defined.
How can I declare interface to children property?
>Solution :
You can set the Tabs Props like that:
interface TabsProps {
children: React.ReactElement<TabProps>[]
};
Thats would "tell" typescript that children are elements that have TabProps, meaning they have label in their props that can be accessed.