我正在VS 2015中使用文档here创建一个测试React Web应用程序,但出现错误
未捕获到的SyntaxError:意外令牌<< / p>
我的代码
class CommentBox extends React.Component {
render() {
return (
<div className="commentBox">
Hello, world! I am a CommentBox.
</div>
);
}
}
ReactDOM.render(
<CommentBox />,
document.getElementById('content')
);
我已安装的nuget软件包
答案 0 :(得分:1)
在图像中,软件包列表用于服务器端渲染。您正在尝试渲染为客户端。
React.Web.MVC4 NuGet软件包用于服务器端。 例如:
class CommentBox extends React.Component {
render() {
return (
<div className="commentBox">
Hello, {this.props.name}! I am a CommentBox.
</div>
);
}
} /* Script/App.js */
@using React.Web.mvc
@Html.React("CommentBox",new{
name="John"
}) /* Index.cshtml */
namespace MyApp
{
public static class ReactConfig
{
public static void Configure()
{
ReactSiteConfiguration.Configuration = new ReactSiteConfiguration()
.AddScript("~/script/App.js");
}
}
} /* AppStart/reactConfig.cs */