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);