You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReactfrom"react";import{Router,Route,Link,Switch}from"toy-react-router";constApp=()=>{return(<Router><Switch><Routepath="/"exact>
This is MainPage
<Linkto="/1">to page 1</Link></Route><Routepath="/1">
This is Page 1
<Linkto="/2">to page 2</Link></Route><Routepath="/2">
This is Page 2
<Linkto="/">to mainpage</Link></Route><Route> No Match </Route></Switch></Router>);};exportdefaultApp;
Component
Router : The common low-level interface for all router components.
Route : Render when its path matches the current URL.
path: string
exact: boolean
When true, will only match if the path matches the location.pathname exactly.
Switch : Renders the first child <Route> that matches the location.
Link : Acts similar to <a> tag without refresh.
to: string
Redirect : Rendering a will navigate to a new location.