diff --git a/src/components/SubmissionDetail.tsx b/src/components/SubmissionDetail.tsx index ee188664e..a02eca19d 100644 --- a/src/components/SubmissionDetail.tsx +++ b/src/components/SubmissionDetail.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter"; +import { PrismAsyncLight as SyntaxHighlighter } from "react-syntax-highlighter"; import { oneDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; import { SubmissionServiceModel } from "../typings/submission"; import { CopyToClipboard } from "react-copy-to-clipboard"; @@ -29,7 +29,7 @@ const SubmissionDetail: React.FC = (props) => { - {props.data.uid} + {props.data.UID} {props.data.problem.slug} {props.data.language} diff --git a/src/components/SubmissionTable.tsx b/src/components/SubmissionTable.tsx index 77e86edb2..6933d960a 100644 --- a/src/components/SubmissionTable.tsx +++ b/src/components/SubmissionTable.tsx @@ -32,8 +32,8 @@ const SubmissionTable: React.FC = (props) => { - {props.data.map((submission) => ( - navigate(submission.uid)}> + {props.data.map((submission, idx) => ( + navigate(submission.UID)} key={idx}> {submission.problem.title} {submission.user.name} {submission.language} diff --git a/src/hooks/problem.ts b/src/hooks/problem.ts index 70d642241..be6c72814 100644 --- a/src/hooks/problem.ts +++ b/src/hooks/problem.ts @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { ProblemServiceModel } from "../typings/problem"; import { ProblemService } from "../api/problem"; @@ -6,6 +6,11 @@ export const useProblem = (slug: string, fallback?: () => void) => { const [problem, setProblem] = useState( null, ); + const fallbackRef = useRef(fallback); + + useEffect(() => { + fallbackRef.current = fallback; + }, [fallback]); useEffect(() => { ProblemService.getProblem(slug) @@ -14,9 +19,9 @@ export const useProblem = (slug: string, fallback?: () => void) => { }) .catch((err) => { console.log(err); - fallback?.(); + fallbackRef.current?.(); }); - }, [slug, fallback]); + }, [slug]); function getProblem() { return problem; diff --git a/src/mocks/rest/submission.ts b/src/mocks/rest/submission.ts index 22f527279..80ba5efe8 100644 --- a/src/mocks/rest/submission.ts +++ b/src/mocks/rest/submission.ts @@ -3,7 +3,7 @@ import { SubmissionServiceModel } from "../../typings/submission"; const submissions: SubmissionServiceModel.SubmissionInfo[] = [ { - uid: "1", + UID: "1", user: { account: "user-1", name: "User 1", @@ -18,7 +18,7 @@ const submissions: SubmissionServiceModel.SubmissionInfo[] = [ status: "finished", }, { - uid: "2", + UID: "2", user: { account: "user-2", name: "User 2", diff --git a/src/typings/submission.ts b/src/typings/submission.ts index 835ee4697..a8f903c59 100644 --- a/src/typings/submission.ts +++ b/src/typings/submission.ts @@ -3,7 +3,7 @@ import { UserServiceModel } from "./user"; export namespace SubmissionServiceModel { export interface SubmissionInfo { - uid: string; + UID: string; user: UserServiceModel.UserInfo; problem: ProblemServiceModel.ProblemInfo; language: string;