I am using useEffect
hook to fetch data from the server and these data are passed to a list, when I Signup I am getting a warning like below
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 getUserData = () => {
axios.get(`${API_URL}`).then((res) => {
if (res.data) {
setUserData(res.data);
}
});
};
useEffect(() => {
getUserData();
}, []);
const logout = () => {
signout(() => {
history.push('/signin');
});
};
return (
<div>
<button onClick={() => logout()}>Sign out </button>
</div>
);