15 lines
298 B
JavaScript
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);
|
|
};
|