Skip to content

Commit 98d8dff

Browse files
committed
perf: uninstall classnames, install clsx
1 parent 46aa19e commit 98d8dff

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@
4747
},
4848
"dependencies": {
4949
"@babel/runtime": "^7.11.1",
50-
"classnames": "^2.2.1",
51-
"rc-motion": "^2.4.4",
52-
"@rc-component/util": "^1.3.0"
50+
"@rc-component/util": "^1.3.0",
51+
"clsx": "^2.1.1",
52+
"rc-motion": "^2.4.4"
5353
},
5454
"devDependencies": {
5555
"@rc-component/father-plugin": "^2.0.1",
5656
"@rc-component/np": "^1.0.0",
5757
"@testing-library/jest-dom": "^5.16.5",
5858
"@testing-library/react": "^14.2.1",
5959
"@testing-library/user-event": "^14.5.2",
60-
"@types/classnames": "^2.2.9",
6160
"@types/jest": "^29.2.4",
61+
"@types/node": "^24.5.2",
6262
"@types/react": "^18.3.11",
6363
"@types/react-dom": "^18.3.1",
6464
"@umijs/fabric": "^3.0.0",

src/MotionThumb.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
22
import { composeRef } from '@rc-component/util/lib/ref';
3-
import classNames from 'classnames';
3+
import { clsx } from 'clsx';
44
import CSSMotion from 'rc-motion';
55
import * as React from 'react';
66
import type { SegmentedValue } from '.';
@@ -211,7 +211,7 @@ export default function MotionThumb(props: MotionThumbInterface) {
211211
const motionProps = {
212212
ref: composeRef(thumbRef, ref),
213213
style: mergedStyle,
214-
className: classNames(`${prefixCls}-thumb`, motionClassName),
214+
className: clsx(`${prefixCls}-thumb`, motionClassName),
215215
};
216216

217217
if (process.env.NODE_ENV === 'test') {

src/index.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
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';
4-
import classNames from 'classnames';
4+
import { clsx } from 'clsx';
55
import * as React from 'react';
66

77
import MotionThumb from './MotionThumb';
@@ -132,9 +132,7 @@ const InternalSegmentedOption: React.FC<{
132132
};
133133
const itemContent: React.ReactNode = (
134134
<label
135-
className={classNames(className, {
136-
[`${prefixCls}-item-disabled`]: disabled,
137-
})}
135+
className={clsx(className, { [`${prefixCls}-item-disabled`]: disabled })}
138136
style={style}
139137
onMouseDown={onMouseDown}
140138
>
@@ -151,10 +149,7 @@ const InternalSegmentedOption: React.FC<{
151149
onKeyUp={onKeyUp}
152150
/>
153151
<div
154-
className={classNames(
155-
`${prefixCls}-item-label`,
156-
segmentedClassNames?.label,
157-
)}
152+
className={clsx(`${prefixCls}-item-label`, segmentedClassNames?.label)}
158153
title={title}
159154
role="radio"
160155
aria-checked={checked}
@@ -189,6 +184,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
189184
} = props;
190185

191186
const containerRef = React.useRef<HTMLDivElement>(null);
187+
192188
const mergedRef = React.useMemo(
193189
() => composeRef<HTMLDivElement>(containerRef, ref),
194190
[containerRef, ref],
@@ -281,7 +277,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
281277
itemRender={itemRender}
282278
key={optionValue}
283279
prefixCls={prefixCls}
284-
className={classNames(
280+
className={clsx(
285281
segmentedOption.className,
286282
`${prefixCls}-item`,
287283
segmentedClassNames?.item,
@@ -314,7 +310,7 @@ const Segmented = React.forwardRef<HTMLDivElement, SegmentedProps>(
314310
tabIndex={disabled ? undefined : 0}
315311
style={style}
316312
{...divProps}
317-
className={classNames(
313+
className={clsx(
318314
prefixCls,
319315
{
320316
[`${prefixCls}-rtl`]: direction === 'rtl',

0 commit comments

Comments
 (0)