Anchor links working locally but not when deployed (React)

Relative links in my project works locally but when I deployed it on render, they're not working
15 Replies
13eck
13eck3w ago
What’s your code look like? Without code we can only guess (badly).
Vikrant Tanwar
Vikrant TanwarOP3w ago
This is my live project link https://portfolio-q79b.onrender.com
ἔρως
ἔρως3w ago
the rendered output isnt always as useful as having the code and the ability to run it
Vikrant Tanwar
Vikrant TanwarOP3w ago
GitHub
GitHub - vikranttanwar04/Portfolio: Vikrant Tanwar Portfolio
Vikrant Tanwar Portfolio. Contribute to vikranttanwar04/Portfolio development by creating an account on GitHub.
Vikrant Tanwar
Vikrant TanwarOP3w ago
Please do something I am stuck in this since last week
13eck
13eck3w ago
Website works for me
13eck
13eck3w ago
Might have been a cache issue 🤷
ἔρως
ἔρως3w ago
the "show work" didnt work for me, and it was the only one you didnt click also, if you refresh, it doesnt work seems to be a misconfiguration on where you deployed your portfolio
Karol
Karol3w ago
@Vikrant Tanwar same here, show work button doesn't work. I think you messed up Router configuration in Main.jsx, you should wrap the paths with ErrorBoundary element.
Karol
Karol3w ago
also, when you are using React Router use Links or Navlinks instead of vanilla a elements. https://reactrouter.com/api/components/NavLink https://reactrouter.com/api/components/Link
Vikrant Tanwar
Vikrant TanwarOP3w ago
I have used Links tag for Navbar items so they work but what about a tags in the project they are not working So, a tag cannot be used in reactjs ever? Yes exactly this is the only issue
Karol
Karol3w ago
you can, but Navlink for example is perfect use case for your navigation bar. Just read the documentation that I've attached and you should spot benefits easily.
Vikrant Tanwar
Vikrant TanwarOP3w ago
Thankyou, I'll do it by Navlink but if ever I want to do it with anchor tag how would I do it?
Karol
Karol3w ago
Navlink and Link are just extended anchor tags available only in React Router. In plain React project you'd just use regular anchor tag. You can see that when you use inspector in browser, even if you use Link or Navlink, it will show it as an anchor and do additional job in the background.
Vikrant Tanwar
Vikrant TanwarOP3w ago
Ok Thankyou Mr @Karol

Did you find this page helpful?