Set default color to undefined

This commit is contained in:
jeffvli 2022-12-31 03:41:18 -08:00
parent 58ed2f3706
commit 00a21269dd

View file

@ -5,7 +5,7 @@ export const useFastAverageColor = (
src?: string | null, src?: string | null,
aglorithm?: 'dominant' | 'simple' | 'sqrt', aglorithm?: 'dominant' | 'simple' | 'sqrt',
) => { ) => {
const [color, setColor] = useState('rgba(0, 0, 0, 0)'); const [color, setColor] = useState<string | undefined>(undefined);
useEffect(() => { useEffect(() => {
const fac = new FastAverageColor(); const fac = new FastAverageColor();
@ -24,7 +24,8 @@ export const useFastAverageColor = (
return setColor(color.rgb); return setColor(color.rgb);
}) })
.catch((e) => { .catch((e) => {
console.log(e); console.log('Error fetching average color', e);
return setColor('rgba(0, 0, 0, 0)');
}); });
} }