Commit b6c1ba34 authored by 天马流星拳's avatar 天马流星拳

fix(HomePage): 修复排行榜数据更新时状态闪烁问题

在获取排行榜信息后,先清空状态再设置新数据以避免UI闪烁
parent 6c59e854
......@@ -67,6 +67,7 @@ class HomePage extends React.Component<any, any> {
}
// 获取排行榜信息
getQueryRankInfo = async (type) => {
console.log("🚀 ~ HomePage ~ type:", type)
const {success, code , data , message } = await API.queryRankInfo({type: type});
if (data) {
......@@ -76,10 +77,19 @@ class HomePage extends React.Component<any, any> {
})
// 格式化我的排名收益率
data.myRank.score = this.formatProfit(data.myRank.score)
// 先清空数据
this.setState({
rankOptions: data?.rankOptions || [],
rankInfos: data?.rankInfos || [],
myRank: data?.myRank || {},
rankOptions: [],
rankInfos: [],
myRank: {},
}, () => {
// 然后再赋值
this.setState({
rankOptions: data?.rankOptions || [],
rankInfos: data?.rankInfos || [],
myRank: data?.myRank || {},
})
})
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment