settimeout 显示进度条 500ms
settimeout to show progressbar for 500ms
props.loadingStatus.state(来自服务器的值)(值可以是未开始、运行、已完成)
取决于 loadingstatus 的值,即如果 运行 则显示进度条 + 如果状态 == 完成速度快于 500 毫秒,则使进度条可见 500 毫秒。
当前结果:
我能够看到加载栏,但即使在 500 毫秒后它也是可见的。我不确定我的逻辑哪里出了问题。
const App =() => {
const [LoadStat, setLoadStat] = React.useState(props.loadingStatus.state);
React.useEffect(() => {
setTimeout(() => {
if (LoadStat === Running) {
setLoadStat(props.loadingStatus.state);
}
}, 500);
}, []);
return (
<>
{LoadStat && (
<ProgressBar
minValue={0}
maxValue={100}
progress={percentage}
/>
)}
</>
);
}
}
React.useEffect(() => {
if (LoadStat === Running) {
setLoadStat(props.loadingStatus.state);
}
else{
setTimeout(() => {
// hide the progressBar
}, 500);
}
}, []);
我不知道这是否回答了你的问题,但这是我从你的请求中得到的。这样,progressBar 将在每次 loadStatus 更改时更新,但会在终止后 500 毫秒消失。
props.loadingStatus.state(来自服务器的值)(值可以是未开始、运行、已完成) 取决于 loadingstatus 的值,即如果 运行 则显示进度条 + 如果状态 == 完成速度快于 500 毫秒,则使进度条可见 500 毫秒。
当前结果: 我能够看到加载栏,但即使在 500 毫秒后它也是可见的。我不确定我的逻辑哪里出了问题。
const App =() => {
const [LoadStat, setLoadStat] = React.useState(props.loadingStatus.state);
React.useEffect(() => {
setTimeout(() => {
if (LoadStat === Running) {
setLoadStat(props.loadingStatus.state);
}
}, 500);
}, []);
return (
<>
{LoadStat && (
<ProgressBar
minValue={0}
maxValue={100}
progress={percentage}
/>
)}
</>
);
}
}
React.useEffect(() => {
if (LoadStat === Running) {
setLoadStat(props.loadingStatus.state);
}
else{
setTimeout(() => {
// hide the progressBar
}, 500);
}
}, []);
我不知道这是否回答了你的问题,但这是我从你的请求中得到的。这样,progressBar 将在每次 loadStatus 更改时更新,但会在终止后 500 毫秒消失。