Hi, I have a question about this situation below.
import { useState, useEffect } from "react";
import { useRafLoop } from "react-use";
export default function AppleDrop() {
const [distance, setDistance] = useState(4000);
const [loopStop] = useRafLoop(() => {
setDistance(distance => distance -20);
});
useEffect(() => {
if (distance <= 200) {
loopStop(); <--- Is there no problem with using like this?
}
}, [distance]);
return (
/.../
);
}
It works fine now, but I’m not sure if this is the way react-use recommends using it.