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

Commit 7cd50f4

Browse files
committed
fix(tabs): removed useCallback from tabs component
it wouldn't update the active tab
1 parent a8b45ad commit 7cd50f4

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/components/Tabs/Tabs.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Basic.args = {
1515
items: [
1616
{
1717
id: 'tab1',
18-
label: 'tab1',
18+
label: 'tab12',
1919
content: <div>Tab 1</div>
2020
},
2121
{

src/components/Tabs/Tabs.tsx

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import clsx from 'clsx';
2-
import React, { useCallback, useMemo, useState } from 'react';
2+
import React, { useMemo, useState } from 'react';
33

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

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

31-
const selectTab = useCallback(
32-
(item: ITabItem) => {
33-
if (item.disabled) return;
31+
const selectTab = (item: ITabItem) => {
32+
if (item.disabled) return;
3433

35-
setActiveTab(item.id);
36-
onChange?.(item.id);
37-
},
38-
[onChange]
39-
);
34+
setActiveTab(item.id);
35+
onChange?.(item.id);
36+
};
4037

4138
const content = useMemo(
4239
() => items.find((item) => item.id === activeTab)?.content,

0 commit comments

Comments
 (0)