fix(history,workout-builder): memoize async load functions with useCallback

This commit is contained in:
2026-08-12 12:59:27 +02:00
parent 2bb4225260
commit 2096489fd1
2 changed files with 6 additions and 6 deletions
@@ -27,15 +27,15 @@ export function HistoryScreen() {
const [sessions, setSessions] = useState<SessionRow[]>([]);
const [refreshing, setRefreshing] = useState(false);
const loadSessions = async () => {
const loadSessions = useCallback(async () => {
const data = await getAllSessions();
setSessions(data as SessionRow[]);
};
}, []);
useFocusEffect(
useCallback(() => {
loadSessions();
}, [])
}, [loadSessions])
);
const onRefresh = async () => {
@@ -24,7 +24,7 @@ export function WorkoutListScreen() {
const [workouts, setWorkouts] = useState<WorkoutRow[]>([]);
const [refreshing, setRefreshing] = useState(false);
const loadWorkouts = async () => {
const loadWorkouts = useCallback(async () => {
const data = await getAllWorkouts();
const rows = data as WorkoutRow[];
@@ -42,12 +42,12 @@ export function WorkoutListScreen() {
);
setWorkouts(withDistance);
};
}, []);
useFocusEffect(
useCallback(() => {
loadWorkouts();
}, [])
}, [loadWorkouts])
);
const onRefresh = async () => {