Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Need to link dynamically to an external URL in React

I am trying to create a list of users and have an inline text link to each user’s Facebook page. I need this link to be created dynamically from a database where the URL is saved as facebook.com/userpage.

This information is being saved from a form, so I’d prefer the user to not have to enter "http://www" when inputting the data.

Is it possible to use an href to do this? Something like this (which obviously does not work):

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<a href="http://www.{user.facebook}">FB profile</a>

>Solution :

Assuming you are using react router,

<Link to={"http://www.facebook.com/"+ user.facebook} target="_blank" rel="noopener noreferrer" />

Since React Router version 5.0.1, you can use

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading