chore: refactor changes

This commit is contained in:
gitstart 2022-12-08 15:18:16 +00:00
parent e6e1e6b1e0
commit ea90b2367b

View File

@ -216,16 +216,11 @@ const useColorInput = (
// Reset state when initialValue changes (when resetting controls)
useEffect(() => {
if (initialValue !== undefined) {
const parsed = parseValue(initialValue);
setValue(initialValue);
setColor(parsed);
setColorSpace(parsed.colorSpace);
return;
}
setValue('');
setColor(undefined);
setColorSpace(ColorSpace.HEX);
const nextValue = initialValue || '';
const nextColor = parseValue(nextValue);
setValue(nextValue);
setColor(nextColor);
setColorSpace(nextColor?.colorSpace || ColorSpace.HEX);
}, [initialValue]);
const realValue = useMemo(