From cdb480d1281e594190aea1123ff1c33a95f6f42f Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Fri, 27 Sep 2024 11:36:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DuseRef=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=BC=95=E8=B5=B7=E7=9A=84color=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E5=86=85=E9=83=A8=E5=B1=9E=E6=80=A7=E6=9C=AA=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E8=87=B4=E7=9A=84=E5=9C=A8Form=E4=B8=ADreset?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E7=9A=84=E6=AD=BB=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/color-picker/components/panel/index.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/color-picker/components/panel/index.tsx b/src/color-picker/components/panel/index.tsx index 54518c5546..b3e9dd2652 100644 --- a/src/color-picker/components/panel/index.tsx +++ b/src/color-picker/components/panel/index.tsx @@ -58,6 +58,13 @@ const Panel = forwardRef((props, ref) => { }); const colorInstanceRef = useRef(new Color(innerValue || defaultEmptyColor)); + useEffect(() => { + colorInstanceRef.current = new Color(innerValue || defaultEmptyColor); + return () => { + colorInstanceRef.current = null; + }; + }, [innerValue, defaultEmptyColor]); + const getModeByColor = colorInstanceRef.current.isGradient ? 'linear-gradient' : 'monochrome'; const formatRef = useRef(colorInstanceRef.current.isGradient ? 'CSS' : format ?? 'RGB');