📅  最后修改于: 2022-03-11 15:01:39.632000             🧑  作者: Mango
//Custom Hook
function usePrevious(value) {
const ref = useRef();
useEffect(() => {
ref.current = value;
});
return ref.current;
}
// Use it in useEffect
const Component = (props) => {
const {receiveAmount, sendAmount } = props
const prevAmount = usePrevious(receiveAmount);
useEffect(() => {
if(prevAmount.receiveAmount !== receiveAmount) {
// process here
}
}, [receiveAmount])
}