Skip to content

Instantly share code, notes, and snippets.

@elzup
Created Jun 14, 2021
Embed
What would you like to do?
fitty for react
import { useEffect, useRef } from 'react'
import fitty from 'fitty'
export function useFitty() {
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
if (!ref.current) return
fitty(ref.current)
ref.current.addEventListener('fit', (e) => {
console.log(e)
})
}, [ref.current])
return [ref] as const
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment