Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
fix(tabs): removed useCallback from tabs component
Browse files Browse the repository at this point in the history
it wouldn't update the active tab
  • Loading branch information
fritzschoff committed Jun 28, 2022
1 parent a8b45ad commit 7cd50f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/Tabs/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Basic.args = {
items: [
{
id: 'tab1',
label: 'tab1',
label: 'tab12',
content: <div>Tab 1</div>
},
{
Expand Down
15 changes: 6 additions & 9 deletions src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import React, { useCallback, useMemo, useState } from 'react';
import React, { useMemo, useState } from 'react';

import { Tab } from '../Tab/Tab';

Expand Down Expand Up @@ -28,15 +28,12 @@ export const Tabs: React.FC<TabsProps> = ({
}) => {
const [activeTab, setActiveTab] = useState(initial);

const selectTab = useCallback(
(item: ITabItem) => {
if (item.disabled) return;
const selectTab = (item: ITabItem) => {
if (item.disabled) return;

setActiveTab(item.id);
onChange?.(item.id);
},
[onChange]
);
setActiveTab(item.id);
onChange?.(item.id);
};

const content = useMemo(
() => items.find((item) => item.id === activeTab)?.content,
Expand Down

0 comments on commit 7cd50f4

Please sign in to comment.