Skip to content

Commit

Permalink
Tabs: Use index instead of random number for keys
Browse files Browse the repository at this point in the history
  • Loading branch information
drublic committed Dec 3, 2020
1 parent 49adbc8 commit 6251214
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,16 @@ class Tabs extends React.Component<TabsProps, TabsState> {
variant={isScrollable ? "scrollable" : undefined}
scrollButtons="auto"
>
{data.map((item) => (
<Tab
key={`tab-${(Math.random() * 10000).toFixed(4)}`}
label={item.title}
/>
{data.map((item, index) => (
<Tab key={`tab-${index}`} label={item.title} />
))}
</MaterialTabs>
</AppBar>

{data.map((item, index) => {
if (value === index) {
return (
<TabContainer
key={`tabcontainer-${(Math.random() * 10000).toFixed(4)}`}
>
<TabContainer key={`tabcontainer-${index}`}>
{item.content}
</TabContainer>
);
Expand Down

0 comments on commit 6251214

Please sign in to comment.