import { Box } from "@chakra-ui/react"; import { useEffect, useRef, useState } from "react"; interface Props { color: string; setColor: (color: string) => void; } const ColorPicker: React.FC = ({ color, setColor }) => { const [colorInternal, setColorInternal] = useState(color); const ref = useRef(null); useEffect(() => { const timer = setTimeout(() => setColor(colorInternal), 250); return () => clearTimeout(timer); }, [colorInternal]); return ( <> setColorInternal(e.target.value)} /> ref.current?.click()} /> ); }; export default ColorPicker;