From 5235b137c2308a7290466105ba8347dfe93e8f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Wed, 10 Sep 2025 10:04:52 +0800 Subject: [PATCH] refactor: Upgrade utils and replace useMergedState --- package.json | 2 +- src/index.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 219af08..a258874 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", "rc-motion": "^2.4.4", - "@rc-component/util": "^1.1.0" + "@rc-component/util": "^1.3.0" }, "devDependencies": { "@rc-component/father-plugin": "^2.0.1", diff --git a/src/index.tsx b/src/index.tsx index de918fc..8556f3f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,4 +1,4 @@ -import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; +import useControlledState from '@rc-component/util/lib/hooks/useControlledState'; import omit from '@rc-component/util/lib/omit'; import { composeRef } from '@rc-component/util/lib/ref'; import classNames from 'classnames'; @@ -200,10 +200,10 @@ const Segmented = React.forwardRef( // Note: We should not auto switch value when value not exist in options // which may break single source of truth. - const [rawValue, setRawValue] = useMergedState(segmentedOptions[0]?.value, { + const [rawValue, setRawValue] = useControlledState( + defaultValue ?? segmentedOptions[0]?.value, value, - defaultValue, - }); + ); // ======================= Change ======================== const [thumbShow, setThumbShow] = React.useState(false);