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)

13 lines (9 loc) 288 B
import { useEffect, useRef } from 'react'; const usePrevious = (value, { initializeWithValue = false } = {}) => { const ref = useRef(initializeWithValue ? value : null); useEffect(() => { ref.current = value; }, [value]); return ref.current; }; export default usePrevious;