Link and Route components, import and use - KatyaHorton/Udacity-MyReads-PROJECT GitHub Wiki

Link component

  1. Install Link component in both BooksSerach and BooksShelf components:
import { Link } from 'react-router-dom' 
  1. Create Link in the render() method in
  • BooksSearch component:
<Link
  to='/'
  className="close-search">
   Close
</Link>
  • BooksShelf component:
<Link
 to='/search'
  className="open-search">
   Open
</Link>

Route component

  1. imports Route component to App component:
import { Route } from 'react-router-dom'
  1. Display either BooksShelf or BooksSearch component depending on the path:
      <div className="app">
        <Route exact path='/'
			render={() =>
			(<BooksShelf />	
		)}/>
		 
		<Route path='/search'
			render={() =>
			(<BooksSearch />	
		)}/>
      </div>
⚠️ **GitHub.com Fallback** ⚠️