Skip to content

Commit 4b00c44

Browse files
EmilyyyLiu刘欢
andauthored
refactor: Upgrade utils and replace useMergedState (#303)
Co-authored-by: 刘欢 <[email protected]>
1 parent 13dcd71 commit 4b00c44

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@babel/runtime": "^7.11.1",
5050
"classnames": "^2.2.1",
5151
"rc-motion": "^2.4.4",
52-
"@rc-component/util": "^1.1.0"
52+
"@rc-component/util": "^1.3.0"
5353
},
5454
"devDependencies": {
5555
"@rc-component/father-plugin": "^2.0.1",

src/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
1+
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
22
import omit from '@rc-component/util/lib/omit';
33
import { composeRef } from '@rc-component/util/lib/ref';
44
import classNames from 'classnames';
@@ -200,10 +200,10 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
200200

201201
// Note: We should not auto switch value when value not exist in options
202202
// which may break single source of truth.
203-
const [rawValue, setRawValue] = useMergedState(segmentedOptions[0]?.value, {
203+
const [rawValue, setRawValue] = useControlledState(
204+
defaultValue ?? segmentedOptions[0]?.value,
204205
value,
205-
defaultValue,
206-
});
206+
);
207207

208208
// ======================= Change ========================
209209
const [thumbShow, setThumbShow] = React.useState(false);

0 commit comments

Comments
 (0)