DEV Community

Discussion on: 🍦 Cancel Properly HTTP Requests in React Hooks and avoid Memory Leaks 🚨

Collapse
 
viclafouch profile image
Victor de la Fouchardière

It's the same approch for redux. And I think Axios provide a cancel function.

Collapse
 
hemant profile image
Hemant Joshi • Edited

But I don't see a need for, never used Cancel kind of fun before also built some stuffs in React-Redux never saw console with such errors.......

const listArticles =()=> async(dispatch)=>{


    try{
        dispatch({type: ARTICLE_LIST_REQUEST});
        const {data}= await axios.get('https://dev.to/api/articles?username=hemant')
        dispatch({type:ARTICLE_LIST_SUCCESS, payload: data})
    }
    catch(error){
        dispatch({type:ARTICLE_LIST_FAIL, payload:error.message})

    }
}

I feel like your talking about dispatch........

Thread Thread
 
hemant profile image
Hemant Joshi

+1. I am really new to React about 3-4 Months and would like to know in redux

Thread Thread
 
gautamkrishnar profile image
Gautam Krishna R

This thing happens every time if you are using react hooks: reactjs.org/docs/hooks-intro.html

Thread Thread
 
hemant profile image
Hemant Joshi

Thanks × 1000 👍.