import React, { useImperativeHandle, useRef, useState } from 'react';
import { Wrapper, TabBar, ContentArea, TabItem } from './style';
import { ITabs, ITabPanel } from './types';
import { usePrevious } from 'utils/hooks';
import Carousel from '../carousel';
export const Tabs = function(
{
defaultActiveIndex = 0,
defaultActiveKey,
tabsLocation = 'top',
onChange,
animation = true,
showUnderLine = true,
size = 'default',
tabHeaderAlign,
children,
width,
height,
...rest
}: ITabs,
imp: any
) {
const [activeIndex, setActive] = useState(defaultActiveIndex);
const ref: any = useRef();
const titles = React.Children.map(children, element => {
if (!React.isValidElement(element)) return;
const { title } = element.props;
return title;
}).filter(Boolean);
useImperativeHandle(
imp,
() => {
return { setActive };
},
[]
);
return (