Categories
React Answers

How to fix React Router v4 routes not working?

Spread the love

Sometimes, we want to fix React Router v4 routes not working.

In this article, we’ll look at how to fix React Router v4 routes not working.

How to fix React Router v4 routes not working?

To fix React Router v4 routes not working, we may need the exact prop to make React Router search for an exact path match.

For instance, we write

<Route exact path="/" component={Home} />;

to add the exact prop so that going to / will render the Home component.

Conclusion

To fix React Router v4 routes not working, we may need the exact prop to make React Router search for an exact path match.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *