|
1 | 1 | import './css/index.css';
|
2 | 2 | import { useState, lazy, Suspense, useEffect } from 'react';
|
| 3 | +import { useParams } from "react-router-dom"; |
3 | 4 | import { FaArrowLeft, FaArrowRight, FaHome, FaBars } from "react-icons/fa";
|
4 | 5 | import "./css/lessonMenu.css";
|
5 |
| -import hljs from "highlight.js"; |
6 |
| -import "highlight.js/styles/monokai.css"; |
| 6 | +import hljs from "highlight.js"; |
| 7 | +import "highlight.js/styles/monokai.css"; |
7 | 8 |
|
8 | 9 | const theme = localStorage.getItem("theme");
|
9 | 10 | switch(theme) {
|
@@ -53,10 +54,10 @@ const lessons = [
|
53 | 54 | {id: 0, title: "Data types", content: () => {
|
54 | 55 | const Comp = lazy(() => import("./lessons/Lesson5.jsx"));
|
55 | 56 | return <Comp/>;
|
56 |
| - }}, |
57 |
| - {id: 1, title: "Variables", content: () => { |
58 |
| - const Comp = lazy(() => import("./lessons/Lesson6.jsx")); |
59 |
| - return <Comp/>; |
| 57 | + }}, |
| 58 | + {id: 1, title: "Variables", content: () => { |
| 59 | + const Comp = lazy(() => import("./lessons/Lesson6.jsx")); |
| 60 | + return <Comp/>; |
60 | 61 | }}
|
61 | 62 | ] // Unit 1
|
62 | 63 | ]
|
@@ -90,7 +91,7 @@ function NavBar(props) {
|
90 | 91 | if (props.unit - 1 < 0) {
|
91 | 92 | console.log("This is the first lesson. Cannot go to the previous lesson.");
|
92 | 93 | return "";
|
93 |
| - } |
| 94 | + } |
94 | 95 | let unitId = props.unit;
|
95 | 96 | if (lessons[--unitId]) {
|
96 | 97 | previousInfo = {unit: unitId, lesson: lessons[unitId].length - 1};
|
@@ -169,19 +170,20 @@ function SideBar(props) {
|
169 | 170 | )
|
170 | 171 | }
|
171 | 172 |
|
172 |
| -function LessonMenu({ match: { params }}) { |
| 173 | +function LessonMenu(props) { |
| 174 | + let params = useParams(); |
173 | 175 | let [unit, setUnit] = useState(params.unit);
|
174 | 176 | let [id, setId] = useState(params.id);
|
175 |
| - let [sideBarShouldAppear, setSideBarShouldAppear] = useState(false); |
176 |
| - |
177 |
| - function LoadingText() { |
178 |
| - useEffect(() => { |
179 |
| - return () => { |
180 |
| - hljs.highlightAll(); |
181 |
| - } |
182 |
| - }, []); |
183 |
| - |
184 |
| - return <main><h1>Loading lesson...</h1></main>; |
| 177 | + let [sideBarShouldAppear, setSideBarShouldAppear] = useState(false); |
| 178 | + |
| 179 | + function LoadingText() { |
| 180 | + useEffect(() => { |
| 181 | + return () => { |
| 182 | + hljs.highlightAll(); |
| 183 | + } |
| 184 | + }, []); |
| 185 | + |
| 186 | + return <main><h1>Loading lesson...</h1></main>; |
185 | 187 | }
|
186 | 188 |
|
187 | 189 | function getLessonContent() {
|
|
0 commit comments