{props.panes.map(pane => {
@@ -18,7 +18,7 @@ export default () => {
= ({ renderTabBar, ...restProps }) => {
+const TabNavListWrapper: React.FC = ({ tabBarRender, ...restProps }) => {
const { tabs } = React.useContext(TabContext);
- if (renderTabBar) {
+ if (tabBarRender) {
const tabNavBarProps = {
...restProps,
// Legacy support. We do not use this actually
@@ -21,7 +21,7 @@ const TabNavListWrapper: React.FC = ({ renderTabBar, ...
)),
};
- return renderTabBar(tabNavBarProps, TabNavList);
+ return tabBarRender(tabNavBarProps, TabNavList);
}
return ;
diff --git a/src/TabNavList/index.tsx b/src/TabNavList/index.tsx
index 124583e1..151ed988 100644
--- a/src/TabNavList/index.tsx
+++ b/src/TabNavList/index.tsx
@@ -17,7 +17,7 @@ import type {
AnimatedConfig,
EditableConfig,
OnTabScroll,
- RenderTabBar,
+ TabBarRender,
SizeInfo,
TabBarExtraContent,
TabPosition,
@@ -42,7 +42,7 @@ export interface TabNavListProps {
moreTransitionName?: string;
mobile: boolean;
tabBarGutter?: number;
- renderTabBar?: RenderTabBar;
+ tabBarRender?: TabBarRender;
className?: string;
style?: React.CSSProperties;
locale?: TabsLocale;
diff --git a/src/Tabs.tsx b/src/Tabs.tsx
index 3876e85e..e34d0901 100644
--- a/src/Tabs.tsx
+++ b/src/Tabs.tsx
@@ -13,7 +13,7 @@ import type {
AnimatedConfig,
EditableConfig,
OnTabScroll,
- RenderTabBar,
+ TabBarRender,
Tab,
TabBarExtraContent,
TabPosition,
@@ -46,7 +46,9 @@ export interface TabsProps
defaultActiveKey?: string;
direction?: 'ltr' | 'rtl';
animated?: boolean | AnimatedConfig;
- renderTabBar?: RenderTabBar;
+ /** @deprecated Please use `tabBarRender` instead */
+ renderTabBar?: TabBarRender;
+ tabBarRender?: TabBarRender;
tabBarExtraContent?: TabBarExtraContent;
tabBarGutter?: number;
tabBarStyle?: React.CSSProperties;
@@ -94,6 +96,7 @@ const Tabs = React.forwardRef((props, ref) => {
moreTransitionName,
destroyInactiveTabPane,
renderTabBar,
+ tabBarRender: customizeTabBarRender,
onChange,
onTabClick,
onTabScroll,
@@ -186,6 +189,8 @@ const Tabs = React.forwardRef((props, ref) => {
indicator,
};
+ const tabBarRender = customizeTabBarRender ?? renderTabBar
+
return (
((props, ref) => {
)}
{...restProps}
>
-
+
{
label: React.ReactNode;
}
-type RenderTabBarProps = {
+type TabBarRenderProps = {
id: string;
activeKey: string;
animated: AnimatedConfig;
@@ -47,8 +47,8 @@ type RenderTabBarProps = {
panes: React.ReactNode;
};
-export type RenderTabBar = (
- props: RenderTabBarProps,
+export type TabBarRender = (
+ props: TabBarRenderProps,
DefaultTabBar: React.ComponentType,
) => React.ReactElement;
diff --git a/tests/index.test.tsx b/tests/index.test.tsx
index bb377a73..1d35095a 100644
--- a/tests/index.test.tsx
+++ b/tests/index.test.tsx
@@ -305,22 +305,22 @@ describe('Tabs.Basic', () => {
});
});
- describe('renderTabBar', () => {
+ describe('tabBarRender', () => {
it('works', () => {
- const renderTabBar = jest.fn((props, Component) => {
+ const tabBarRender = jest.fn((props, Component) => {
return (
{node => {node}}
);
});
- const { container } = render(getTabs({ renderTabBar }));
+ const { container } = render(getTabs({ tabBarRender }));
expect(container.querySelector('.my-wrapper')).toBeTruthy();
expect(container.querySelector('.my-node')).toBeTruthy();
- expect(renderTabBar).toHaveBeenCalled();
+ expect(tabBarRender).toHaveBeenCalled();
});
it('has panes property in props', () => {
- const renderTabBar = props => {
+ const tabBarRender = props => {
return (
{props.panes.map(pane => (
@@ -331,7 +331,7 @@ describe('Tabs.Basic', () => {
);
};
- const { container } = render(getTabs({ renderTabBar }));
+ const { container } = render(getTabs({ tabBarRender }));
expect(container.querySelector('[data-key="light"]')).toBeTruthy();
expect(container.querySelector('[data-key="bamboo"]')).toBeTruthy();
expect(container.querySelector('[data-key="cute"]')).toBeTruthy();
diff --git a/tests/swipe.js b/tests/swipe.js
index 27b97e9f..1d05e529 100644
--- a/tests/swipe.js
+++ b/tests/swipe.js
@@ -37,7 +37,7 @@ class NormalTabs extends Component {
this.root = root;
}}
defaultActiveKey="8"
- renderTabBar={() => (
+ tabBarRender={() => (
{
this.tabBar = tabBar;
@@ -81,7 +81,7 @@ describe('rc-swipeable-tabs', () => {
const wrapper = mount(
}
+ tabBarRender={() => }
renderTabContent={() => }
onChange={handleChange}
>