UNPKG

@atlaskit/motion

Version:

A set of utilities to apply motion in your application.

13 lines 444 B
import { useCallback, useRef } from 'react'; /** * Will return a tuple of the element and the callback ref to set. * This is used as a work around for using `useRef` directly with Typescript * as the types don't flow through as one would expect. */ export const useElementRef = () => { const elementRef = useRef(null); const setRef = useCallback(ref => { elementRef.current = ref; }, []); return [elementRef.current, setRef]; };