diff --git a/src/rate/Rate.tsx b/src/rate/Rate.tsx
index a358921ec..63813044e 100644
--- a/src/rate/Rate.tsx
+++ b/src/rate/Rate.tsx
@@ -11,11 +11,20 @@ import { rateDefaultProps } from './defaultProps';
export interface RateProps extends TdRateProps, StyledProps {}
+// 评分图标
+// fix: 2550
+const RateIcon = ({ icon, ...props }) => {
+ const { StarFilledIcon } = useGlobalIcon({ StarFilledIcon: TdStarFilledIcon });
+ if (React.isValidElement(icon)) {
+ return React.cloneElement(icon, props);
+ }
+ return ;
+};
+
const Rate = forwardRef((props: RateProps, ref: React.Ref) => {
const { allowHalf, color, count, disabled, gap, showText, size, texts, icon, className, style, onChange } = props;
const { classPrefix } = useConfig();
- const { StarFilledIcon } = useGlobalIcon({ StarFilledIcon: TdStarFilledIcon });
const [starValue = 0, setStarValue] = useControlled(props, 'value', onChange);
const [hoverValue = undefined, setHoverValue] = useState(undefined);
@@ -25,14 +34,6 @@ const Rate = forwardRef((props: RateProps, ref: React.Ref) => {
const activeColor = Array.isArray(color) ? color[0] : color;
const defaultColor = Array.isArray(color) ? color[1] : 'var(--td-bg-color-component)';
- // 评分图标
- const RateIcon = (props: any) => {
- if (React.isValidElement(icon)) {
- return React.cloneElement(icon, props);
- }
- return ;
- };
-
const getStarValue = (event: MouseEvent, index: number) => {
if (allowHalf) {
const rootNode = rootRef.current;
@@ -87,19 +88,19 @@ const Rate = forwardRef((props: RateProps, ref: React.Ref) => {
{showText ? (
-
+
-
+
) : (
<>
-
+
-
+
>
)}