File tree Expand file tree Collapse file tree 1 file changed +19
-15
lines changed
Expand file tree Collapse file tree 1 file changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -4,22 +4,26 @@ import cn from 'classnames'
44require ( './Tabs.scss' )
55
66
7- const Tabs = ( { activeKey, children, onSelect} ) => (
8- < div >
9- < div className = "tabs" >
10- < ul >
11- { children . map ( ( { props : { title, eventKey} } ) =>
12- < li key = { eventKey } onClick = { ( e ) => onSelect ( eventKey , e ) } className = { cn ( { active : activeKey === eventKey } ) } >
13- < a > { title } </ a >
14- </ li >
15- ) }
16- </ ul >
17- </ div >
18- < div className = "tab-content" >
19- { children . filter ( ( { props : { eventKey} } ) => eventKey === activeKey ) [ 0 ] }
7+ const Tabs = ( { activeKey, children, onSelect} ) => {
8+ const renderTabPill = ( { props : { title, eventKey} } ) => (
9+ < li key = { eventKey } className = { cn ( { active : activeKey === eventKey } ) } >
10+ < a onClick = { function ( e ) { onSelect ( eventKey , e ) } } > { title } </ a >
11+ </ li >
12+ )
13+ const activeChild = ( { props : { eventKey} } ) => eventKey === activeKey
14+ return (
15+ < div >
16+ < div className = "tabs" >
17+ < ul >
18+ { children . map ( renderTabPill ) }
19+ </ ul >
20+ </ div >
21+ < div className = "tab-content" >
22+ { children . filter ( activeChild ) [ 0 ] }
23+ </ div >
2024 </ div >
21- </ div >
22- )
25+ )
26+ }
2327
2428Tabs . propTypes = {
2529 /**
You can’t perform that action at this time.
0 commit comments