[英]React: Unterminated JSX contents
Why do I get the error Unterminated JSX contents
for the closing div
-element? 为什么我得到关闭
div
-element的错误Unterminated JSX contents
? What am I doing wrong? 我究竟做错了什么?
export default class Search extends Component {
render() {
return (
<div class="ui icon input">
<input type="text" placeholder="Search...">
<i class="circular search link icon"></i>
</div>
);
}
}
Issue is, you forgot to close your input
element, in JSX
you have to close all the opened tags
properly like in XML
. 问题是,你忘了关闭你的
input
元素,在JSX
你必须像在XML
一样正确地关闭所有打开的tags
。
JSX is a XML-like syntax extension to ECMAScript without any defined semantics.
JSX是ECMAScript的类似XML的语法扩展,没有任何定义的语义。 It's intended to be used by various preprocessors (transpilers) to transform these tokens into standard ECMAScript.
它旨在被各种预处理器(转换器)用于将这些令牌转换为标准ECMAScript。
One more thing, class
is a reserved keyword, to apply any css
class instead of using the class
keyword, use className
. 还有一件事,
class
是保留关键字,要应用任何css
类而不是使用class
关键字,请使用className
。
Try this: 试试这个:
export default class Search extends Component {
render() {
return (
<div className="ui icon input">
<input type="text" placeholder="Search..."/>
<i className="circular search link icon"></i>
</div>
);
}
}
Your input
JSX element is not terminated, it is missing a closing tag. 您的
input
JSX元素未终止,它缺少结束标记。
And class
is a reserved name in Javascript. 而
class
是Javascript中的保留名称。 You need to use the className
prop instead. 您需要使用
className
prop。
<div className="ui icon input">
<input type="text" placeholder="Search..." />
<i className="circular search link icon"></i>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.