3

I want to put some xml in the DOM so that it can be accessed by another Component. But when I try to render it, I keep getting prop unknown errors, such as:

warning.js:36 Warning: Unknown prop colour on <category> tag. Remove this prop from the element. For details, see https://facebook.github.io/react/warnings/unknown-prop.html

I don't want React to interpret those attributes as props! It's just xml, not a react component!

This is the code I have:

class DefaultToolbox extends Component {
  render() {
    // static xml
    return (
      <xml id="toolbox" style={{display: "none"}}>
        <category name="Logic" colour="#5C81A6" />
        // ... etc etc
      </xml>
    );
  }
}
0

1 Answer 1

3
return (<span dangerouslySetInnerHTML={{ __html: `<xml ..> ... </xml>` }}/>);

for more information: https://facebook.github.io/react/docs/dom-elements.html#dangerouslysetinnerhtml

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.