I have a login form with a submit button that trigger handleSubmit function, in this function i am doing my axios stuff
const handleSubmit = (e) => {
e.preventDefault();
//action creator
loginUser(loginData)
}
My Redux action creator:
export const loginUser = (loginData) => (dispatch) => {
axios.post('/signin', loginData)
.then(res => {
let FBIdToken = `Bearer ${res.data.token}`;
localStorage.setItem('FBIdToken', FBIdToken);
})
.catch(err => {
dispatch({
type: SET_ERRORS,
payload: err.response ? err.response.data : {}
});
})
}
Now after unmounting the login component i get that error:
index.js:1 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.
I know what is my problem is , i need to clean up my axios request, How to clean axios request in my case??
setStatesomewhere in yourlogincomponent that's fired after umnounting. - k-wasilewskihistoryobject onloginUsercomes from ? - h1b9bindex.js:) - k-wasilewski