Skip to content

Commit

Permalink
improve code splitting
Browse files Browse the repository at this point in the history
the problem page is still large b/c of the dependency on the editor, but at least the home pages should load quickly
  • Loading branch information
varun7654 committed May 6, 2024
1 parent eba72df commit 13e2bf0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import React, {lazy} from 'react';
import {BrowserRouter as Router, Link, Route, Routes, useLocation} from 'react-router-dom';
import './App.css';
import 'highlight.js/styles/atom-one-dark.min.css';
import {Problem} from "./problem/Problem";
import Home from './Home';
import LoginButton from "./auth/LoginButton";
import LoginSuccess from "./auth/LoginSuccess";
import {createTheme, Shadows} from "@mui/material";

export const API_URL = "https://codehelp.api.dacubeking.com/";
Expand Down Expand Up @@ -69,6 +66,11 @@ export function Header() {
}
}

const Home = lazy(() => import("./Home"));
const Problem = lazy(() => import("./problem/Problem"));
const LoginSuccess = lazy(() => import("./auth/LoginSuccess"));


function App() {
return (
<Router>
Expand Down
2 changes: 1 addition & 1 deletion src/problem/Problem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function getStorageKey(id: string, userName: string | undefined) {
return "problem " + id;
}

export function Problem() {
export default function Problem() {
const [problemData, setProblemData] = useState(null as unknown as ProblemData);
const {"*": id} = useParams();
const [userData, setUserData] = useState(null as unknown as UserData);
Expand Down

0 comments on commit 13e2bf0

Please sign in to comment.