From 1d0b4f8b50213ac1ad35ac6d8d3151226134e6ec Mon Sep 17 00:00:00 2001 From: Warre Provoost <133233646+warreprovoost@users.noreply.github.com> Date: Sun, 12 May 2024 16:42:56 +0200 Subject: [PATCH] Fix flickering with data loader (#348) * added loader * added loader * linter * fix name --- .../components/Courses/AllCoursesTeacher.tsx | 11 +++- .../Courses/CourseUtilComponents.tsx | 58 +------------------ .../src/components/Courses/CourseUtils.tsx | 52 ++++++++++++++++- 3 files changed, 61 insertions(+), 60 deletions(-) diff --git a/frontend/src/components/Courses/AllCoursesTeacher.tsx b/frontend/src/components/Courses/AllCoursesTeacher.tsx index facfa9c2..12b736a8 100644 --- a/frontend/src/components/Courses/AllCoursesTeacher.tsx +++ b/frontend/src/components/Courses/AllCoursesTeacher.tsx @@ -3,7 +3,7 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import { SideScrollableCourses } from "./CourseUtilComponents"; -import { Course, callToApiToCreateCourse } from "./CourseUtils"; +import {Course, callToApiToCreateCourse, ProjectDetail} from "./CourseUtils"; import { Title } from "../Header/Title"; import { useLoaderData } from "react-router-dom"; @@ -12,7 +12,12 @@ import { useLoaderData } from "react-router-dom"; */ export function AllCoursesTeacher(): JSX.Element { const [open, setOpen] = useState(false); - const courses = (useLoaderData() as Course[]); + const loader = useLoaderData() as { + courses: Course[]; + projects: { [courseId: string]: ProjectDetail[] } + }; + const courses = loader.courses; + const projects = loader.projects; const [courseName, setCourseName] = useState(''); const [error, setError] = useState(''); @@ -49,7 +54,7 @@ export function AllCoursesTeacher(): JSX.Element { <>