UNPKG

@newrelic/gatsby-theme-newrelic

Version:

[![Community Project header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Project.png)](https://opensource.newrelic.com/oss-category/#community-project)

22 lines (16 loc) 345 B
import { useEffect, useRef } from 'react'; const useSyncedRef = (ref) => { const innerRef = useRef(); useEffect(() => { if (!ref) { return; } if (typeof ref === 'function') { ref(innerRef.current); } else { ref.current = innerRef.current; } }); return innerRef; }; export default useSyncedRef;