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

16 lines
298 B
JavaScript
Raw Normal View History

2020-07-21 00:08:03 +02: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);
};