Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reactjs - anchor tag link

I'm trying to figure out how to output these lines of codes into something like

<a href="http://">SOMETHING</a>

enter image description here

BASE_URL as enter image description here

When I run this code, I get this output in the browser: enter image description here

What's the correct way of doing this?

like image 727
Peter Wateber Avatar asked Sep 20 '13 09:09

Peter Wateber


People also ask

Can I use anchor tag in react JS?

In React, relative URLs should always be handled by the link tag provided by the React Router, and pure anchor tags should only be used for absolute paths. You can also think of relative URLs as in-app navigation, for example navigating to a particular route of the app and absolute paths as external links.

How do you pass props through link in React?

To recap, if you need to pass data from Link through to the new component that's being rendered, pass Link s a state prop with the data you want to pass through. Then, to access the Link s state property from the component that's being rendered, use the useLocation Hook to get access to location.


1 Answers

In this case, you just need to lose the quotes:

<a href={BASE_URL}>

You can play with the JSX compiler at babeljs to get a slightly better idea of what JS it compiles into.

like image 124
Sophie Alpert Avatar answered Sep 30 '22 03:09

Sophie Alpert