useCallbackRef
API
import useCallbackRef from '@restart/hooks/useCallbackRef'
useCallbackRef
<TValue>() => [TValue | null,(ref: TValue | null) => void]A convenience hook around
useState
designed to be paired with the component callback ref api. Callback refs are useful overuseRef()
when you need to respond to the ref being set instead of lazily accessing it in an effect.const [element, attachRef] = useCallbackRef<HTMLDivElement>()useEffect(() => {if (!element) returnconst calendar = new FullCalendar.Calendar(element)return () => {calendar.destroy()}}, [element])return <div ref={attachRef} />Return Value [TValue | null,(ref: TValue | null) => void]