Created
May 6, 2021 04:47
-
-
Save basith374/03849129a3c7e544b213f0043e2fe840 to your computer and use it in GitHub Desktop.
color picker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useRef } from 'react' | |
import iro from '@jaames/iro' | |
function ColorPicker({ setColor, color }) { | |
const ref = useRef() | |
const colorPicker = useRef() | |
useEffect(() => { | |
const cp = (colorPicker.current = new iro.ColorPicker(ref.current, { | |
color | |
})) | |
cp.on('color:change', (color) => setColor(color.hexString)) | |
}, []) | |
return <div ref={ref} /> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment