-
-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathWrapper.tsx
More file actions
34 lines (27 loc) · 1.06 KB
/
Wrapper.tsx
File metadata and controls
34 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// zombieJ: To compatible with `tabBarRender` usage.
import * as React from 'react';
import type { TabNavListProps } from '.';
import TabNavList from '.';
import TabContext from '../TabContext';
import TabPane from '../TabPanelList/TabPane';
export type TabNavListWrapperProps = Required<Omit<TabNavListProps, 'children' | 'className'>> &
TabNavListProps;
// We have to create a TabNavList components.
const TabNavListWrapper: React.FC<TabNavListWrapperProps> = ({ tabBarRender, ...restProps }) => {
const { tabs } = React.useContext(TabContext);
if (tabBarRender) {
const tabNavBarProps = {
...restProps,
// Legacy support. We do not use this actually
panes: tabs.map<React.ReactNode>(({ label, key, ...restTabProps }) => (
<TabPane tab={label} key={key} tabKey={key} {...restTabProps} />
)),
};
return tabBarRender(tabNavBarProps, TabNavList);
}
return <TabNavList {...restProps} />;
};
if (process.env.NODE_ENV !== 'production') {
TabNavListWrapper.displayName = 'TabNavListWrapper';
}
export default TabNavListWrapper;