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 {
render() {
...
<div id="registration-success">
<h1>You have registered successfully!</h1>
<p>Where do you want to go next?</p>
<Link to='/'><Button title="Home"></Button></Link>
<Link to='/login'><Button title="Login"></Button></Link>
</div>
}
}