React: Embedding Creative Commons License on a React.js application

Created on 24 Aug 2019  路  1Comment  路  Source: facebook/react

Hello, I'm getting this error when I embed a Creative Commons Licence on my React.js application:

SyntaxError: D:Node.js Projects\React Apps\Project Name\components\ComponentName.js: Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can turn on the 'throwIfNamespace' flag to bypass this warning.

  28 |           </a>
  29 |           <br />
> 30 |           <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">
     |                 ^

You can generate your Creative Commons Licence' HTML code at: https://creativecommons.org/choose/

I already tried to replace xmlns:dct with xmlnsDct and the other namespace tags with their camelCase forms but that just caused another problem making xmlnsDct and the others non-valid properties.

Any solution for this?

Most helpful comment

Yeah, jsx doesn't have support for namespaces unfortunately. Here's a workaround that behaves like you'd want it to.

<span  {...{ 'xmlns:dct': "http://purl.org/dc/terms/" }} property="dct:title">
   this works!
</span>

A last resort alternative is to use dangerouslySetInnerHTML on the parent, but I hope the above workaround is a better option for you.

>All comments

Yeah, jsx doesn't have support for namespaces unfortunately. Here's a workaround that behaves like you'd want it to.

<span  {...{ 'xmlns:dct': "http://purl.org/dc/terms/" }} property="dct:title">
   this works!
</span>

A last resort alternative is to use dangerouslySetInnerHTML on the parent, but I hope the above workaround is a better option for you.

Was this page helpful?
0 / 5 - 0 ratings