Rick Rick - 1 year ago 88
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?

Answer Source

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>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download