Created
June 14, 2021 09:45
-
-
Save elzup/f7805a581fea36355d1e1c8ee953b50c to your computer and use it in GitHub Desktop.
fitty for react
This file contains 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 { 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