p5.js-web-editor/client/utils/custom-hooks.js

16 lines
298 B
JavaScript
Raw Normal View History

2020-07-20 22:08:03 +00:00
import React, { useEffect, useRef } from 'react';
export const noop = () => {};
export const useDidUpdate = (callback, deps) => {
const hasMount = useRef(false);
useEffect(() => {
if (hasMount.current) {
callback();
} else {
hasMount.current = true;
}
}, deps);
};