Skip to content

Instantly share code, notes, and snippets.

@basith374
Created May 6, 2021 04:47
Show Gist options
  • Save basith374/03849129a3c7e544b213f0043e2fe840 to your computer and use it in GitHub Desktop.
Save basith374/03849129a3c7e544b213f0043e2fe840 to your computer and use it in GitHub Desktop.
color picker
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