File tree Expand file tree Collapse file tree 3 files changed +60
-12
lines changed
Expand file tree Collapse file tree 3 files changed +60
-12
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : dynamic-extra
3+ nav :
4+ title : Demo
5+ path : /demo
6+ ---
7+
8+ <code src =" ../examples/dynamic-extra.tsx " ></code >
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import Tabs from '../../src' ;
3+ import type { TabsProps } from '../../src' ;
4+ import '../../assets/index.less' ;
5+
6+ const items : TabsProps [ 'items' ] = [ ] ;
7+ for ( let i = 0 ; i < 50 ; i += 1 ) {
8+ items . push ( {
9+ key : String ( i ) ,
10+ label : `Tab ${ i } ` ,
11+ children : `Content of ${ i } ` ,
12+ } ) ;
13+ }
14+ export default ( ) => {
15+ const [ key , setKey ] = React . useState ( '0' ) ;
16+
17+ const extra = React . useMemo ( ( ) => {
18+ if ( key === '0' ) {
19+ return (
20+ < div > 额外内容</ div >
21+ )
22+ }
23+ return null
24+ } , [ key ] )
25+
26+ return (
27+ < div style = { { maxWidth : 550 } } >
28+ < Tabs
29+ activeKey = { key }
30+ onChange = { ( curKey ) => setKey ( curKey ) }
31+ tabBarExtraContent = { extra }
32+ defaultActiveKey = "8"
33+ moreIcon = "..."
34+ items = { items }
35+ />
36+ </ div >
37+ ) ;
38+ } ;
Original file line number Diff line number Diff line change @@ -426,16 +426,17 @@ function TabNavList(props: TabNavListProps, ref: React.Ref<HTMLDivElement>) {
426426 >
427427 < ExtraContent ref = { extraLeftRef } position = "left" extra = { extra } prefixCls = { prefixCls } />
428428
429- < div
430- className = { classNames ( wrapPrefix , {
431- [ `${ wrapPrefix } -ping-left` ] : pingLeft ,
432- [ `${ wrapPrefix } -ping-right` ] : pingRight ,
433- [ `${ wrapPrefix } -ping-top` ] : pingTop ,
434- [ `${ wrapPrefix } -ping-bottom` ] : pingBottom ,
435- } ) }
436- ref = { tabsWrapperRef }
437- >
438- < ResizeObserver onResize = { onListHolderResize } >
429+ < ResizeObserver onResize = { onListHolderResize } >
430+ < div
431+ className = { classNames ( wrapPrefix , {
432+ [ `${ wrapPrefix } -ping-left` ] : pingLeft ,
433+ [ `${ wrapPrefix } -ping-right` ] : pingRight ,
434+ [ `${ wrapPrefix } -ping-top` ] : pingTop ,
435+ [ `${ wrapPrefix } -ping-bottom` ] : pingBottom ,
436+ } ) }
437+ ref = { tabsWrapperRef }
438+ >
439+ < ResizeObserver onResize = { onListHolderResize } >
439440 < div
440441 ref = { tabListRef }
441442 className = { `${ prefixCls } -nav-list` }
@@ -463,8 +464,9 @@ function TabNavList(props: TabNavListProps, ref: React.Ref<HTMLDivElement>) {
463464 style = { indicatorStyle }
464465 />
465466 </ div >
466- </ ResizeObserver >
467- </ div >
467+ </ ResizeObserver >
468+ </ div >
469+ </ ResizeObserver >
468470
469471 < OperationNode
470472 { ...props }
You can’t perform that action at this time.
0 commit comments