1
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect, useCallback } from "react";
|
||||
import { View, Text, Image, ScrollView } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
import "@/user_pages/myself/index.scss";
|
||||
@@ -40,13 +40,8 @@ const MyselfPageContent: React.FC = () => {
|
||||
// 确保从编辑页面返回时刷新数据
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading) {
|
||||
load_game_data();
|
||||
}
|
||||
}, [active_tab]);
|
||||
|
||||
const classifyGameRecords = (
|
||||
// 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
|
||||
const classifyGameRecords = useCallback((
|
||||
game_records: TennisMatch[]
|
||||
): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => {
|
||||
const now = new Date().getTime();
|
||||
@@ -64,9 +59,10 @@ const MyselfPageContent: React.FC = () => {
|
||||
finishedGames: [] as TennisMatch[],
|
||||
}
|
||||
);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const load_game_data = async () => {
|
||||
// 使用 useCallback 包装 load_game_data,避免每次渲染都创建新函数
|
||||
const load_game_data = useCallback(async () => {
|
||||
try {
|
||||
if (!user_info || !("id" in user_info)) {
|
||||
return;
|
||||
@@ -89,7 +85,13 @@ const MyselfPageContent: React.FC = () => {
|
||||
} catch (error) {
|
||||
console.error("加载球局数据失败:", error);
|
||||
}
|
||||
};
|
||||
}, [active_tab, user_info, classifyGameRecords]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading) {
|
||||
load_game_data();
|
||||
}
|
||||
}, [loading, load_game_data]);
|
||||
|
||||
const handle_follow = async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user