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)

21 lines (15 loc) 384 B
import { useEffect, useRef } from 'react'; import warning from 'warning'; const useWarning = (test, message, { once = true } = {}) => { const warnRef = useRef(); useEffect(() => { if (once && warnRef.current) { return; } warning(test, message); if (!test) { warnRef.current = true; } }, [test, message, once]); }; export default useWarning;