The Link Component - KatyaHorton/Udacity-React-practice GitHub Wiki

Link component

The way the user navigates through the app:

  • user clicks link =>
  • Link component talks to the browser router =>
  • tells the BrowserRouter to update URL

Very accessible, will work using:

  • keyboard
  • right click- and open new window etc

**Will do what user expects the link on the web to do"

Add a Link component

1 Import Link component to the ListContacts.js:

import { Link } from 'react-router-dom'   

2 Create a link in the render() method (in our case, update the link we created before without using Link component):

<Link
 to='/create'
 //onClick={this.props.onNavigate} is done by ReactRouter, so we don't need it anymore
 className='add-contact'
> Add Contact </Link>

By passing a to property to the Link component, you tell your app which path to route to.


⚠️ **GitHub.com Fallback** ⚠️