https://codesandbox.io/s/heuristic-lamport-xzzmh?file=/src/App.js
const useWillMount = (fn) => {
const willMount = useRef(true);
useEffect(() => {
willMount.current = false;
}, []);
if (willMount.current) {
fn && fn();
}
};
https://codesandbox.io/s/heuristic-lamport-xzzmh?file=/src/App.js
const useWillMount = (fn) => {
const willMount = useRef(true);
useEffect(() => {
willMount.current = false;
}, []);
if (willMount.current) {
fn && fn();
}
};
让时间为你证明