Navigation

The last important component classes provided by React Router are the navigational components, of which there are three types:

  • <Link>: This will render an anchor (<a>) component, for example, <Link to='/'>Home</Link>
  • <NavLink>: This is a special type of <Link> that will add a class to the element if the pathname matches the to prop, for example, <NavLink to='/profile' activeClassName='active'>Profile</NavLink>
  • <Redirect>: This is a component that will navigate to the to prop, for example, <Redirect to='/login'/>

Therefore, we can update our #registration-success element to include links to the Home and Login page (which we haven't implemented yet!):

import { Link } from 'react-router-dom';...class RegistrationForm extends React.Component ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.