Skip to content

Commit 84a60c6

Browse files
author
刘欢
committed
refactor: Upgrade utils and replace useMergedState
1 parent 874875a commit 84a60c6

File tree

10 files changed

+19
-21
lines changed

10 files changed

+19
-21
lines changed

docs/examples/components/TooltipSlider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Slider from 'rc-slider';
33
import type { TooltipRef } from 'rc-tooltip';
44
import Tooltip from 'rc-tooltip';
55
import 'rc-tooltip/assets/bootstrap.css';
6-
import raf from 'rc-util/lib/raf';
6+
import raf from '@rc-component/util/lib/raf';
77
import * as React from 'react';
88

99
interface HandleTooltipProps {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"dependencies": {
4444
"@babel/runtime": "^7.10.1",
4545
"classnames": "^2.2.5",
46-
"rc-util": "^5.36.0"
46+
"@rc-component/util": "^1.3.0"
4747
},
4848
"devDependencies": {
4949
"@rc-component/father-plugin": "^1.0.2",

src/Handles/Handle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cls from 'classnames';
2-
import KeyCode from 'rc-util/lib/KeyCode';
2+
import KeyCode from '@rc-component/util/lib/KeyCode';
33
import * as React from 'react';
44
import SliderContext from '../context';
55
import type { OnStartMove } from '../interface';

src/Slider.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
2+
import useEvent from '@rc-component/util/lib/hooks/useEvent';
3+
import isEqual from '@rc-component/util/lib/isEqual';
4+
import warning from '@rc-component/util/lib/warning';
15
import cls from 'classnames';
2-
import useEvent from 'rc-util/lib/hooks/useEvent';
3-
import useMergedState from 'rc-util/lib/hooks/useMergedState';
4-
import isEqual from 'rc-util/lib/isEqual';
5-
import warning from 'rc-util/lib/warning';
66
import * as React from 'react';
77
import type { HandlesProps, HandlesRef } from './Handles';
88
import Handles from './Handles';
@@ -250,9 +250,7 @@ const Slider = React.forwardRef<SliderRef, SliderProps<number | number[]>>((prop
250250
);
251251

252252
// ============================ Values ============================
253-
const [mergedValue, setValue] = useMergedState<number | number[], number[]>(defaultValue, {
254-
value,
255-
});
253+
const [mergedValue, setValue] = useControlledState(defaultValue, value);
256254

257255
const rawValues = React.useMemo(() => {
258256
const valueList =

src/hooks/useDrag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import useEvent from 'rc-util/lib/hooks/useEvent';
3-
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
2+
import useEvent from '@rc-component/util/lib/hooks/useEvent';
3+
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
44
import { UnstableContext } from '../context';
55
import type { Direction, OnStartMove } from '../interface';
66
import type { OffsetValues } from './useOffset';

src/hooks/useRange.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warning } from 'rc-util/lib/warning';
1+
import { warning } from '@rc-component/util/lib/warning';
22
import { useMemo } from 'react';
33
import type { SliderProps } from '../Slider';
44

tests/Range.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable max-len, no-undef, react/no-string-refs, no-param-reassign, max-classes-per-file */
22
import '@testing-library/jest-dom';
33
import { createEvent, fireEvent, render } from '@testing-library/react';
4-
import keyCode from 'rc-util/lib/KeyCode';
5-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
6-
import { resetWarned } from 'rc-util/lib/warning';
4+
import keyCode from '@rc-component/util/lib/KeyCode';
5+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
6+
import { resetWarned } from '@rc-component/util/lib/warning';
77
import React from 'react';
88
import Slider from '../src';
99

tests/Slider.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import '@testing-library/jest-dom';
22
import { createEvent, fireEvent, render } from '@testing-library/react';
33
import classNames from 'classnames';
4-
import keyCode from 'rc-util/lib/KeyCode';
5-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
4+
import keyCode from '@rc-component/util/lib/KeyCode';
5+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
66
import React from 'react';
77
import Slider from '../src/Slider';
88

tests/common.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable max-len, no-undef */
22
import '@testing-library/jest-dom';
33
import { createEvent, fireEvent, render } from '@testing-library/react';
4-
import KeyCode from 'rc-util/lib/KeyCode';
5-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
4+
import KeyCode from '@rc-component/util/lib/KeyCode';
5+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
66
import React from 'react';
77
import Slider from '../src';
88

tests/marks.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable max-len, no-undef */
22
import '@testing-library/jest-dom';
33
import { fireEvent, render } from '@testing-library/react';
4-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
4+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
55
import React from 'react';
66
import Slider from '../src';
77

0 commit comments

Comments
 (0)