From 79556d21bbb0850883fd73af57f71edfb05dade5 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sun, 28 Sep 2025 13:34:31 +0800 Subject: [PATCH] perf: uninstall classnames, install clsx --- .gitignore | 1 + package.json | 10 ++++++---- src/index.tsx | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 236d3e6..30faecb 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ lib es yarn.lock package-lock.json +pnpm-lock.yaml coverage/ # dumi diff --git a/package.json b/package.json index 68f1da4..03a83ab 100644 --- a/package.json +++ b/package.json @@ -43,13 +43,16 @@ ] }, "dependencies": { - "classnames": "^2.2.1", - "@rc-component/util": "^1.3.0" + "@rc-component/util": "^1.3.0", + "clsx": "^2.1.1" }, "devDependencies": { "@rc-component/father-plugin": "^2.0.0", - "@types/classnames": "^2.2.10", + "@rc-component/np": "^1.0.3", "@types/jest": "^29.4.0", + "@types/node": "^24.5.2", + "@types/react": "^19.1.14", + "@types/react-dom": "^19.1.9", "@umijs/fabric": "^3.0.0", "cheerio": "1.0.0-rc.12", "dumi": "^2.0.0", @@ -64,7 +67,6 @@ "husky": "^8.0.1", "less": "^4.1.3", "lint-staged": "^15.1.0", - "@rc-component/np": "^1.0.3", "prettier": "^3.1.0", "react": "^16.0.0", "react-dom": "^16.0.0", diff --git a/src/index.tsx b/src/index.tsx index 875bd49..08c2c98 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import classNames from 'classnames'; +import { clsx } from 'clsx'; import useControlledState from '@rc-component/util/lib/hooks/useControlledState'; import KeyCode from '@rc-component/util/lib/KeyCode'; @@ -84,7 +84,7 @@ const Switch = React.forwardRef( onClick?.(ret, e); } - const switchClassName = classNames(prefixCls, className, { + const switchClassName = clsx(prefixCls, className, { [`${prefixCls}-checked`]: innerChecked, [`${prefixCls}-disabled`]: disabled, }); @@ -104,13 +104,13 @@ const Switch = React.forwardRef( {loadingIcon} {checkedChildren} {unCheckedChildren}