Samson
Samson

Reputation: 1888

React how to concat an Anchor element (a tag) to string

I am trying to show

        {`I agree to the ${(
          <a href={termsFile} download>
            Terms and Conditions
          </a>
        )}`}

but the text shows up as "I agree to the [object Object]" instead.

Upvotes: 0

Views: 81

Answers (2)

Camilo
Camilo

Reputation: 7184

Simply:

<>
  I agree to the{" "}
  <a href={termsFile} download>
    Terms and Conditions
  </a>
</>

If you write it down in a single line you don't need the {" "}, you can use a normal space:

<>
  I agree to the <a>Terms</a>
</>

Upvotes: 2

Abhishek Kumar Pandey
Abhishek Kumar Pandey

Reputation: 457

Inside your JSX element you can try something like this

    <>
      I agree to the {(
      <a href={termsFile} download>
        Terms and Conditions
      </a>
    )}
   </>

Upvotes: 0

Related Questions