how can I fix this error in my react native, see the code below.
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
const getData = () => {
setIsLoading(true)
axios.get(hosturl.loaduser + userlist.user_id + '&page=' +currentPage)
.then((response) => {
setEvent([...userData, ...response.data.data])
setIsLoading(false)
})
}
useEffect(() => {
getData();
}, [currentPage]);
I did something like this see below but error keep showing.
useEffect(() => {
let isMounted = true;
if (isMounted) getData();
return () => { isMounted = false };
}, [currentPage]);