Skip to content

Commit 5776e33

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 56274cb + 08967cc commit 5776e33

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"dependencies": {
4141
"@rc-component/resize-observer": "^1.0.0",
42-
"@rc-component/util": "^1.2.0",
42+
"@rc-component/util": "^1.3.0",
4343
"@rc-component/motion": "^1.1.3",
4444
"classnames": "2.x",
4545
"@rc-component/dropdown": "~1.0.0",

src/Tabs.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Accessibility https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role
22
import classNames from 'classnames';
3-
import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
3+
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
44
import isMobile from '@rc-component/util/lib/isMobile';
55
import * as React from 'react';
66
import { useEffect, useState } from 'react';
@@ -123,10 +123,10 @@ const Tabs = React.forwardRef<HTMLDivElement, TabsProps>((props, ref) => {
123123
}, []);
124124

125125
// ====================== Active Key ======================
126-
const [mergedActiveKey, setMergedActiveKey] = useMergedState<string>(() => tabs[0]?.key, {
127-
value: activeKey,
128-
defaultValue: defaultActiveKey,
129-
});
126+
const [mergedActiveKey, setMergedActiveKey] = useControlledState<string>(
127+
defaultActiveKey ?? tabs[0]?.key,
128+
activeKey,
129+
);
130130
const [activeIndex, setActiveIndex] = useState(() =>
131131
tabs.findIndex(tab => tab.key === mergedActiveKey),
132132
);
@@ -142,9 +142,7 @@ const Tabs = React.forwardRef<HTMLDivElement, TabsProps>((props, ref) => {
142142
}, [tabs.map(tab => tab.key).join('_'), mergedActiveKey, activeIndex]);
143143

144144
// ===================== Accessibility ====================
145-
const [mergedId, setMergedId] = useMergedState(null, {
146-
value: id,
147-
});
145+
const [mergedId, setMergedId] = useControlledState(null, id);
148146

149147
// Async generate id to avoid ssr mapping failed
150148
useEffect(() => {

0 commit comments

Comments
 (0)