diff --git a/components/ui/color-picker.tsx b/components/ui/color-picker.tsx index 8308c44..28dd035 100644 --- a/components/ui/color-picker.tsx +++ b/components/ui/color-picker.tsx @@ -90,7 +90,7 @@ export const ColorPicker = ({ onChange([rgba[0], rgba[1], rgba[2], next.alpha / 100]) } }, - [onChange], + [onChange, setHueState, setSaturationState, setLightnessState, setAlphaState], ) const setHue = useCallback((next: number) => updateColor({ hue: next }), [updateColor]) @@ -119,6 +119,8 @@ export const ColorPicker = ({ } channelsRef.current = next + // Synchronize the internal channels when the controlled value changes. + // eslint-disable-next-line react-hooks/set-state-in-effect setHueState(next.hue) setSaturationState(next.saturation) setLightnessState(next.lightness) @@ -141,7 +143,7 @@ export const ColorPicker = ({ setMode, }} > -
+ ) } @@ -198,7 +200,7 @@ export const ColorPickerSelection = memo(({ className, ...props }: ColorPickerSe style={{ background: backgroundGradient, }} - {...(props as any)} + {...props} >