DEV Community

Discussion on: Cancelling previous requests in Search bar using Axios in React

Collapse
 
darijavan profile image
RANDRIANANDRAINA Hajanirina Ridjvan

Thanks for the trick.

I think you'd better use reference instead of normal plain variable when it's about storing the cancelToken otherwise the desired value will be lost on each re-render (I know, in this example there won't be any re-render at all since there is no state involved in there, but if it was the case, I think it won't work as expected)