yarn add use-axios-progress-bar or npm i use-axios-progress-bar --save
Find the progress bar component of your dream
Use it
//import your axios instance(or just global axios)importTrackedAxiosInstancefrom"axios";
importuseAxiosProgressBarfrom"use-axios-progress-bar";
/* In DELAY ms minimum after query sent progress will start moving on(smth like throttling to avoid frequent irritating twitches)*/constDELAY=200;
constGlobalProgressBar= () => {
constcurrentProgress=useAxiosProgressBar( TrackedAxiosInstance, DELAY );
/* -1: no activity 0: smth is running, but exact loading/total ratio cannot be calculated 1-100: smth is running and loading/total ratio is known*/return (
<div>Current state: ${currentProgress}</div>
);
}