From 25351b4536e9f8196412623fd081db63f016dc09 Mon Sep 17 00:00:00 2001 From: "R.M Khoshrou" Date: Wed, 6 Nov 2024 22:58:14 +0330 Subject: [PATCH] Update useColorPicker.ts to use current selected value from picker --- src/hooks/useColorPicker.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hooks/useColorPicker.ts b/src/hooks/useColorPicker.ts index 8255dd8..35edbf4 100644 --- a/src/hooks/useColorPicker.ts +++ b/src/hooks/useColorPicker.ts @@ -12,12 +12,16 @@ export const useColorPicker = ( value: string, onChange: (arg0: string) => void ) => { - const colors = getColors(value) + let colors = getColors(value) const { degrees, degreeStr, isGradient, gradientType } = getDetails(value) const { currentColor, selectedColor, currentLeft } = getColorObj(colors) const [previousColors, setPreviousColors] = useState([]) - const getGradientObject = () => { + const getGradientObject = (currentValue: string) => { + if (currentValue) + { + colors = getColors(currentValue) + } if (value) { if (isGradient) { return {