how to stop the loadFriendList when setWorker Value is"0"?
const [worker, setWorker] = useState('1');
function start() {
setInterval(loadFriendList,5000);
}
useEffect(start, []);
function n() {
setWorker("0");
Alert.alert('check', worker);
}
This
useEffecthook fires whenever worker is change.The
useRefhook is holding on to the Interval you set up when page loading, to uniquely identify and run methods likeclearInterval()in futureFinally It Should Look Like