-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 根据activeKey显示额外内容导致最后一个tab点击失效 (#662)
* fix: 根据activeKey显示额外内容导致最后一个tab点击失效 * fix: 添加动态extra demo * chore: back of origin resize --------- Co-authored-by: Bill <[email protected]> Co-authored-by: 二货机器人 <[email protected]>
- Loading branch information
1 parent
0bce955
commit b0febf1
Showing
3 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: dynamic-extra | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/dynamic-extra.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import Tabs from '../../src'; | ||
import type { TabsProps } from '../../src'; | ||
import '../../assets/index.less'; | ||
|
||
const items: TabsProps['items'] = []; | ||
for (let i = 0; i < 50; i += 1) { | ||
items.push({ | ||
key: String(i), | ||
label: `Tab ${i}`, | ||
children: `Content of ${i}`, | ||
}); | ||
} | ||
export default () => { | ||
const [key, setKey] = React.useState('0'); | ||
|
||
const extra = React.useMemo(() => { | ||
if (key === '0') { | ||
return ( | ||
<div>额外内容</div> | ||
) | ||
} | ||
return null | ||
}, [key]) | ||
|
||
return ( | ||
<div style={{ maxWidth: 550 }}> | ||
<Tabs | ||
activeKey={key} | ||
onChange={(curKey) => setKey(curKey)} | ||
tabBarExtraContent={extra} | ||
defaultActiveKey="8" | ||
moreIcon="..." | ||
items={items} | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b0febf1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
tabs – ./
tabs-react-component.vercel.app
tabs-git-master-react-component.vercel.app