The Link Component - KatyaHorton/Udacity-React-practice GitHub Wiki
- 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"
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.