[英]How to add xml to DOM with ReactJS component
I want to put some xml in the DOM so that it can be accessed by another Component. 我想在DOM中放入一些xml,以便其他组件可以访问它。 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.warning.js:36警告:
<category>
标签上的道具colour
未知。 Remove this prop from the element.从元素中删除此道具。 For details, see https://facebook.github.io/react/warnings/unknown-prop.html
有关详细信息,请参见https://facebook.github.io/react/warnings/unknown-prop.html
I don't want React to interpret those attributes as props! 我不希望React将那些属性解释为道具! It's just xml, not a react component!
它只是xml,不是react组件!
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>
);
}
}
return (<span dangerouslySetInnerHTML={{ __html: `<xml ..> ... </xml>` }}/>);
有关更多信息: https : //facebook.github.io/react/docs/dom-elements.html#dangerouslysetinnerhtml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.