I want to create a status bar something like in this : https://vaadin.com/learn/tutorials/using-web-components
This should be called when a user hits an api.
I tried with https://ant.design/components/progress/#header , by continuously changing the progress every 100ms, but how to exactly make it look continuous as in https://vaadin.com/learn/tutorials/using-web-components
useEffect(()=>{
if(loading==true){
setPercent(0)
changePercent()
}
},[loading])
const changePercent=()=>{
if(loading==false){
return
}
if(loadingPercent<99){
const rotation = loadingPercent + 1;
setPercent(rotation)
}else{
setPercent(0)
}
requestAnimationFrame(changePercent);
}
It's showing the progress 1 , and the functions is not being called again
If you're faking the progress just so the user has something to look at, I think you'll get the smoothest results by using requestAnimationFrame instead of setTimeout and using the time since start of the animation to calculate the current "progress"