Home > Blockchain >  How to concatenate string and html element with literals?
How to concatenate string and html element with literals?

Time:02-18

basically trying to combine some text with a link:

  const myText = `${t('privacyTxt')}`   `${<a>{t('privacyLink')}</a>}`;

result:

To learn how we process your data, visit our[object Object]

What am I missing?

CodePudding user response:

You're trying to put JSX inside a template literal. It doesn't belong there.

If you're at the point of dealing with JSX, then everything should be done using JSX and not template literals.

const myText = <>
   {t('privacyTxt')}
   <a>
       {t('privacyLink')}
   </a>
</>;
  • Related