Skip to content

Commit fc8442e

Browse files
committed
perf: uninstall classnames, install clsx
1 parent f755b47 commit fc8442e

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
"dependencies": {
4545
"@rc-component/util": "^1.3.0",
46-
"classnames": "^2.3.2"
46+
"clsx": "^2.1.1"
4747
},
4848
"devDependencies": {
4949
"@rc-component/father-plugin": "^2.0.2",
@@ -52,6 +52,7 @@
5252
"@testing-library/react": "^16.0.1",
5353
"@testing-library/user-event": "^14.5.2",
5454
"@types/jest": "^29.2.2",
55+
"@types/node": "^24.5.2",
5556
"@types/react": "^19.0.8",
5657
"@types/react-dom": "^19.0.3",
5758
"@umijs/fabric": "^4.0.1",

src/Pager.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint react/prop-types: 0 */
2-
import classNames from 'classnames';
2+
import { clsx } from 'clsx';
33
import React from 'react';
44
import type { PaginationProps } from './interface';
55

@@ -32,7 +32,7 @@ const Pager: React.FC<PagerProps> = (props) => {
3232
} = props;
3333
const prefixCls = `${rootPrefixCls}-item`;
3434

35-
const cls = classNames(
35+
const cls = clsx(
3636
prefixCls,
3737
`${prefixCls}-${page}`,
3838
{

src/Pagination.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import classNames from 'classnames';
1+
import { clsx } from 'clsx';
22
import useControlledState from '@rc-component/util/lib/hooks/useControlledState';
33
import KeyCode from '@rc-component/util/lib/KeyCode';
44
import pickAttrs from '@rc-component/util/lib/pickAttrs';
@@ -446,7 +446,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
446446
onClick={jumpPrevHandle}
447447
tabIndex={0}
448448
onKeyDown={runIfEnterJumpPrev}
449-
className={classNames(`${prefixCls}-jump-prev`, {
449+
className={clsx(`${prefixCls}-jump-prev`, {
450450
[`${prefixCls}-jump-prev-custom-icon`]: !!jumpPrevIcon,
451451
})}
452452
>
@@ -461,7 +461,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
461461
onClick={jumpNextHandle}
462462
tabIndex={0}
463463
onKeyDown={runIfEnterJumpNext}
464-
className={classNames(`${prefixCls}-jump-next`, {
464+
className={clsx(`${prefixCls}-jump-next`, {
465465
[`${prefixCls}-jump-next-custom-icon`]: !!jumpNextIcon,
466466
})}
467467
>
@@ -488,7 +488,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
488488

489489
if (current - 1 >= pageBufferSize * 2 && current !== 1 + 2) {
490490
pagerList[0] = React.cloneElement<PagerProps>(pagerList[0], {
491-
className: classNames(
491+
className: clsx(
492492
`${prefixCls}-item-after-jump-prev`,
493493
pagerList[0].props.className,
494494
),
@@ -500,7 +500,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
500500
if (allPages - current >= pageBufferSize * 2 && current !== allPages - 2) {
501501
const lastOne = pagerList[pagerList.length - 1];
502502
pagerList[pagerList.length - 1] = React.cloneElement(lastOne, {
503-
className: classNames(
503+
className: clsx(
504504
`${prefixCls}-item-before-jump-next`,
505505
lastOne.props.className,
506506
),
@@ -526,7 +526,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
526526
onClick={prevHandle}
527527
tabIndex={prevDisabled ? null : 0}
528528
onKeyDown={runIfEnterPrev}
529-
className={classNames(`${prefixCls}-prev`, paginationClassNames?.item, {
529+
className={clsx(`${prefixCls}-prev`, paginationClassNames?.item, {
530530
[`${prefixCls}-disabled`]: prevDisabled,
531531
})}
532532
style={styles?.item}
@@ -555,7 +555,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
555555
onClick={nextHandle}
556556
tabIndex={nextTabIndex}
557557
onKeyDown={runIfEnterNext}
558-
className={classNames(`${prefixCls}-next`, paginationClassNames?.item, {
558+
className={clsx(`${prefixCls}-next`, paginationClassNames?.item, {
559559
[`${prefixCls}-disabled`]: nextDisabled,
560560
})}
561561
style={styles?.item}
@@ -566,7 +566,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
566566
);
567567
}
568568

569-
const cls = classNames(prefixCls, className, {
569+
const cls = clsx(prefixCls, className, {
570570
[`${prefixCls}-start`]: align === 'start',
571571
[`${prefixCls}-center`]: align === 'center',
572572
[`${prefixCls}-end`]: align === 'end',

0 commit comments

Comments
 (0)