Listing 12-4: Multiple routes in a component may have matches
Home Route
Login Route
import {BrowserRouter as Router, Route} from 'react-router-dom';
function HomeScreen(props){
return (
<Router>
<Route path="/listing1204">
<Home />
</Route>
<Route path="/listing1204/login">
<Login />
</Route>
</Router>
)
}
export default HomeScreen;
function Home(){
return (
<p>Home Route</p>
)
}
function Login(){
return (
<p>Login Route</p>
)
}
Download the examples, report issues, and ask/answer questions in the discussion area by visiting the book's github page. All of the code for the book is also available on codesandbox.io for you to play around with.
ReactJS Foundations is published by John Wiley and Sons, Inc and is available in paperback and eBook.