Lesson-8 - React Router
Lesson-8 - React Router
PAGE APPLICATIONS
LESSON 8 – MR. MINH SANG
1
OBJECTIVES
Set up the router module to enable navigation among multiple component views
2
SINGLE PAGE
APPLICATIONS
(SPA) 3
TRADITIONAL WEB SITES
4
SINGLE PAGE APPLICATIONS
5
WHAT IS SINGLE PAGE APPLICATION?
6
CHALLENGES IN SPA
7
REACT ROUTER
8
REACT ROUTER
9
WEB APP ROUTING
Install react-router-dom
Router component: <BrowserRouter>
Enclose your app in <BrowserRouter> </BrowserRouter>
10
ROUTE MATCHING
11
NAVIGATION
12
REACT
ROUTER:
PARAMETERS 13
REACT ROUTER
14
ROUTE PARAMETERS
Route parameters can be specified using a link parameter while specifiyng the link
e.g., <Link to{`/menu/${dish.id}`} >
Using ‘useParams’ Hook to returns an object of key/value pairs of the dynamic
params from the current URL that were matched by the <Route path>
15
EXERCISE 12: REACT ROUTER
16
SUMMARY
Set up the router module to enable navigation among multiple component views
17