Home > Back-end >  React how to concat an Anchor element (a tag) to string
React how to concat an Anchor element (a tag) to string

Time:07-28

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.

CodePudding user response:

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>
</>

CodePudding user response:

Inside your JSX element you can try something like this

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