p5.js-web-editor/client/utils/custom-hooks.js
2020-07-20 19:08:03 -03:00

15 lines
298 B
JavaScript

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);
};