From 298b952755a594906bfa9ce979468545509a8422 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sun, 28 Sep 2025 12:20:40 +0800 Subject: [PATCH] perf: uninstall classnames, install clsx --- package.json | 8 ++++---- src/InputNumber.tsx | 2 +- src/StepHandler.tsx | 13 ++++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 8c64200f..d3d14577 100644 --- a/package.json +++ b/package.json @@ -46,10 +46,10 @@ ] }, "dependencies": { - "@rc-component/mini-decimal": "^1.0.1", - "classnames": "^2.2.5", "@rc-component/input": "~1.0.0", - "@rc-component/util": "^1.2.0" + "@rc-component/mini-decimal": "^1.0.1", + "@rc-component/util": "^1.2.0", + "clsx": "^2.1.1" }, "devDependencies": { "@rc-component/father-plugin": "^2.0.2", @@ -57,8 +57,8 @@ "@swc-node/jest": "^1.5.5", "@testing-library/jest-dom": "^6.1.5", "@testing-library/react": "^16.0.0", - "@types/classnames": "^2.2.9", "@types/jest": "^29.2.4", + "@types/node": "^24.5.2", "@types/react": "^18.0.26", "@types/react-dom": "^18.0.9", "@types/responselike": "^1.0.0", diff --git a/src/InputNumber.tsx b/src/InputNumber.tsx index 5ef0697a..8cb3d822 100644 --- a/src/InputNumber.tsx +++ b/src/InputNumber.tsx @@ -6,7 +6,7 @@ import getMiniDecimal, { validateNumber, ValueType, } from '@rc-component/mini-decimal'; -import clsx from 'classnames'; +import { clsx } from 'clsx'; import { BaseInput } from '@rc-component/input'; import { useLayoutUpdateEffect } from '@rc-component/util/lib/hooks/useLayoutEffect'; import proxyObject from '@rc-component/util/lib/proxyObject'; diff --git a/src/StepHandler.tsx b/src/StepHandler.tsx index 0855866a..51fd56d6 100644 --- a/src/StepHandler.tsx +++ b/src/StepHandler.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/no-unknown-property */ import * as React from 'react'; -import cls from 'classnames'; +import { clsx } from 'clsx'; import raf from '@rc-component/util/lib/raf'; import SemanticContext from './SemanticContext'; @@ -22,6 +22,7 @@ export interface StepHandlerProps { downDisabled?: boolean; onStep: (up: boolean, emitter: 'handler' | 'keyboard' | 'wheel') => void; } + export default function StepHandler({ prefixCls, upNode, @@ -64,7 +65,9 @@ export default function StepHandler({ React.useEffect( () => () => { onStopStep(); - frameIds.current.forEach((id) => raf.cancel(id)); + frameIds.current.forEach((id) => { + raf.cancel(id); + }); }, [], ); @@ -72,10 +75,10 @@ export default function StepHandler({ // ======================= Render ======================= const handlerClassName = `${prefixCls}-handler`; - const upClassName = cls(handlerClassName, `${handlerClassName}-up`, { + const upClassName = clsx(handlerClassName, `${handlerClassName}-up`, { [`${handlerClassName}-up-disabled`]: upDisabled, }); - const downClassName = cls(handlerClassName, `${handlerClassName}-down`, { + const downClassName = clsx(handlerClassName, `${handlerClassName}-down`, { [`${handlerClassName}-down-disabled`]: downDisabled, }); @@ -94,7 +97,7 @@ export default function StepHandler({ }; return ( -