@@ -2,7 +2,7 @@ import React from "react";
22import "./main.css" ;
33import "./components/mainContent/navbar.css" ;
44import Navbar from "./components/mainContent/Navbar" ;
5- import { BrowserRouter as Router , Switch , Route } from "react-router-dom " ;
5+ import { BrowserRouter as Router , Routes , Route } from "react-router" ;
66import LandingPage from "./components/LandingPage" ;
77import CollegeAdmissionsUT from "./caseStudies/CollegeAdmissionsUT" ;
88import CaseStudyFacebook from "./caseStudies/CaseStudyFacebook" ;
@@ -15,72 +15,27 @@ function App() {
1515 return (
1616 < div className = "app" >
1717 < Router >
18- { /* conditionally render the heading in navbar */ }
19- < Switch >
20- { /* render default navbar if URL is empty */ }
21- < Route exact path = "/" >
22- < div className = "navbar" >
23- < Navbar path = "/" subtitle = { getHeader ( ) } />
24- </ div >
25- </ Route >
26- { /* pass in URL through params if it's not the default URL */ }
27- < Route
28- path = "/:currentPage"
29- render = { ( input ) => (
30- < div className = "navbar" >
31- < Navbar
32- path = { "/" + input . match . params . currentPage }
33- subtitle = { getHeader ( input . match . params . currentPage ) }
34- />
35- </ div >
36- ) }
37- > </ Route >
38- </ Switch >
18+ < div className = "navbar" >
19+ < Routes >
20+ < Route path = "/" >
21+ < Route index element = { < Navbar /> } />
22+ < Route path = ":currentPage" element = { < Navbar /> } />
23+ </ Route >
24+ </ Routes >
25+ </ div >
3926
40- < Switch >
41- < Route exact path = "/" >
42- < LandingPage />
43- </ Route >
44- < Route path = "/aboutUs" >
45- < AboutUsPage />
46- </ Route >
47- < Route path = "/college" >
48- < CollegeAdmissionsUT />
49- </ Route >
50- < Route path = "/facebook" >
51- < CaseStudyFacebook />
52- </ Route >
53- < Route path = "/facialRecognition" >
54- < FacialRecognition />
55- </ Route >
56- < Route path = "/conclusion" >
57- < ConclusionPage />
58- </ Route >
59- < Route path = "/resources" >
60- < ResourcesPage />
61- </ Route >
62- </ Switch >
27+ < Routes >
28+ < Route exact path = "/" element = { < LandingPage /> } />
29+ < Route path = "/aboutUs" element = { < AboutUsPage /> } />
30+ < Route path = "/college" element = { < CollegeAdmissionsUT /> } />
31+ < Route path = "/facebook" element = { < CaseStudyFacebook /> } />
32+ < Route path = "/facialRecognition" element = { < FacialRecognition /> } />
33+ < Route path = "/conclusion" element = { < ConclusionPage /> } />
34+ < Route path = "/resources" element = { < ResourcesPage /> } />
35+ </ Routes >
6336 </ Router >
6437 </ div >
6538 ) ;
6639}
6740
6841export default App ;
69-
70- //function that renders the heading for the navbar from the route parameters
71- function getHeader ( path ) {
72- let subtitle = "A TeachLA Learning Lab!" ;
73- const pageNames = {
74- aboutUs : "Who's TeachLA?" ,
75- college : "Case Study #1: College Admissions" ,
76- facebook : "Case Study #2: Facebook Ads" ,
77- facialRecognition : "Case Study #3: Facial Recognition" ,
78- conclusion : "In Conclusion..." ,
79- resources : "To Learn More..." ,
80- } ;
81- //return default dictionary value if path is falsy
82-
83- //get the subtitle from our pageNames dictionary if path exists
84- if ( path ) ( { [ path ] : subtitle } = pageNames ) ;
85- return subtitle ;
86- }
0 commit comments