Search code examples
htmlreactjsjsxanchor

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.


Solution

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