Blank Url # href issue fix – React JS

How to fix the href="#" not working issue in React JS. Converting html code to React app – a tag href showing warning or error with #. Here is the solution or fix for this warning created by the react.

HTML Code

<a href="#" className="btn btn-primary"> More </a>

The above code is the normal html code for linking to a new page. This will not work with react and create a warning or error.

So we can fix that issue in multiple ways.

href="#" can be replaced by href="/#"

href="#" can be replaced by href="/"

React Code

<a href="/#" className="btn btn-primary">More</a>

About the Author: smartcoder

You might like

Leave a Reply

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