-
-
Notifications
You must be signed in to change notification settings - Fork 448
Closed
Labels
Description
Hi everyone, I'm having an issue using custom Functional components and TypeScript. The code below won't render the TabPanels, but the Tabs are shown.
import React, { FunctionComponent, ReactElement } from 'react';
import {
Tabs, TabList, TabPanel, Tab,
} from 'react-tabs';
interface TabsProps {
panels: {
title: string;
panelContent?: ReactElement;
}[];
}
const CustomTabPanel: FunctionComponent = ({ children }) => (
<TabPanel>
{children}
</TabPanel>
);
const MyTabs: FunctionComponent<TabsProps> = (props: TabsProps) => {
const {
panels,
} = props;
return (
<Tabs>
<TabList>
{panels.map(({ title }) => <Tab title={title} key={title} />)}
</TabList>
{
panels.map(({ panelContent, title }) => <CustomTabPanel key={title}>{panelContent}</CustomTabPanel>)
}
</Tabs>
);
};
export default MyTabs;
I'm trying to apply this, but I'm not sure how that fits in with my code. Can somebody help?