Rick Rick - 5 months ago 33
Javascript Question

React-Router is refreshing page when I follow a route using <a> tag

I'm building a React app that has links pointing to predefined routes.

<a href="/my/react/route/">Click Here</a>

The routes resolve fine, but it's refreshing the page, thereby slowing down app performance. How do I avoid re-rendering the entire page?


Fix the problem by using the <Link> tag included with react-router.

import React from "react";
import { Link } from 'react-router';

export class ToolTip extends React.Component {
  render() {
    return <Link to="/My/Route"> Click Here </Link>