Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Tabs changes
Browse files Browse the repository at this point in the history
1. simplified as no more need for id or isActive
2. destructure in props
3. remove implicit type form useState hook
  • Loading branch information
W3stside committed Nov 18, 2020
1 parent bb00bef commit 3249eb9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/components/common/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,22 @@ const Wrapper = styled.div`
}
`

const Tabs: React.FC<Props> = (props) => {
const [activeTab, setActiveTab] = useState<number>(1)
const Tabs: React.FC<Props> = ({ tabItems }) => {
const [activeTab, setActiveTab] = useState(1)

return (
<Wrapper>
<ul>
{props.tabItems.map(({ id, title, activeColor }) => (
{tabItems.map(({ id, title, activeColor }) => (
<TabItem
key={id}
id={id}
title={title}
onTabClick={(): void => setActiveTab(id)}
isActive={activeTab === id}
activeColor={activeColor}
activeColor={activeTab === id && activeColor}
/>
))}
</ul>
<TabContent tabItems={props.tabItems} activeTab={activeTab} />
<TabContent tabItems={tabItems} activeTab={activeTab} />
</Wrapper>
)
}
Expand Down

0 comments on commit 3249eb9

Please sign in to comment.