From fab68aa984e809d70a48cc53c37a1ca299d49cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=AA?= <1844749591@qq.com> Date: Fri, 17 Jan 2025 22:16:33 +0800 Subject: [PATCH] feat: retire deprecated api --- docs/demo/renderTabBar-use-panes.md | 8 ----- docs/examples/renderTabBar-use-panes.tsx | 43 ------------------------ src/TabNavList/Wrapper.tsx | 15 ++------- src/Tabs.tsx | 1 - src/interface.ts | 2 -- tests/index.test.tsx | 17 ---------- 6 files changed, 2 insertions(+), 84 deletions(-) delete mode 100644 docs/demo/renderTabBar-use-panes.md delete mode 100644 docs/examples/renderTabBar-use-panes.tsx diff --git a/docs/demo/renderTabBar-use-panes.md b/docs/demo/renderTabBar-use-panes.md deleted file mode 100644 index 616e1cfc..00000000 --- a/docs/demo/renderTabBar-use-panes.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: enderTabBar-use-panes -nav: - title: Demo - path: /demo ---- - - diff --git a/docs/examples/renderTabBar-use-panes.tsx b/docs/examples/renderTabBar-use-panes.tsx deleted file mode 100644 index a976effe..00000000 --- a/docs/examples/renderTabBar-use-panes.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; -import Tabs from '../../src'; -import '../../assets/index.less'; - -const renderTabBar = props => { - return ( -
- {props.panes.map(pane => { - const { key } = pane; - return {key}; - })} -
- ); -}; - -export default () => { - return ( -
- -
- ); -}; diff --git a/src/TabNavList/Wrapper.tsx b/src/TabNavList/Wrapper.tsx index a2b4bd50..b4203554 100644 --- a/src/TabNavList/Wrapper.tsx +++ b/src/TabNavList/Wrapper.tsx @@ -3,25 +3,14 @@ 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> & TabNavListProps; // We have to create a TabNavList components. const TabNavListWrapper: React.FC = ({ renderTabBar, ...restProps }) => { - const { tabs } = React.useContext(TabContext); if (renderTabBar) { - const tabNavBarProps = { - ...restProps, - // Legacy support. We do not use this actually - panes: tabs.map(({ label, key, ...restTabProps }) => ( - - )), - }; - - return renderTabBar(tabNavBarProps, TabNavList); + return renderTabBar(restProps, TabNavList); } return ; diff --git a/src/Tabs.tsx b/src/Tabs.tsx index 7d6df768..6a288859 100644 --- a/src/Tabs.tsx +++ b/src/Tabs.tsx @@ -178,7 +178,6 @@ const Tabs = React.forwardRef((props, ref) => { onTabScroll, extra: tabBarExtraContent, style: tabBarStyle, - panes: null, getPopupContainer, popupClassName, indicator, diff --git a/src/interface.ts b/src/interface.ts index ea7958af..162e1345 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -51,8 +51,6 @@ type RenderTabBarProps = { onTabScroll: OnTabScroll; extra: TabBarExtraContent; style: React.CSSProperties; - /** @deprecated It do not pass real TabPane node. Only for compatible usage. */ - panes: React.ReactNode; }; export type RenderTabBar = ( diff --git a/tests/index.test.tsx b/tests/index.test.tsx index db5bc7d9..a7488dd9 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -310,23 +310,6 @@ describe('Tabs.Basic', () => { expect(container.querySelector('.my-node')).toBeTruthy(); expect(renderTabBar).toHaveBeenCalled(); }); - it('has panes property in props', () => { - const renderTabBar = props => { - return ( -
- {props.panes.map(pane => ( - - tab - - ))} -
- ); - }; - const { container } = render(getTabs({ renderTabBar })); - expect(container.querySelector('[data-key="light"]')).toBeTruthy(); - expect(container.querySelector('[data-key="bamboo"]')).toBeTruthy(); - expect(container.querySelector('[data-key="cute"]')).toBeTruthy(); - }); }); it('destroyInactiveTabPane', () => {