@newrelic/gatsby-theme-newrelic
Version:
[](https://opensource.newrelic.com/oss-category/#community-project)
21 lines (15 loc) • 384 B
JavaScript
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;