- 实现componentDidUpdate的效果
export function useDidUpdate(effect: React.EffectCallback, deps?: React.DependencyList): void {
const time = React.useRef(0);
React.useEffect(() => {
if (++time.current > 1) {
effect();
}
}, deps);
}
export function useDidUpdate(effect: React.EffectCallback, deps?: React.DependencyList): void {
const time = React.useRef(0);
React.useEffect(() => {
if (++time.current > 1) {
effect();
}
}, deps);
}