I'm trying to figure out how to output these lines of codes into something like
<a href="http://">SOMETHING</a>
BASE_URL as
When I run this code, I get this output in the browser:
What's the correct way of doing this?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With