我刚刚安装ReactJS.NET
在我的应用程序中,并计划在单个页面上使用它。我习惯制作“整体”是React(以及Typescript和Webpack)的应用程序。
但是,如果我只是安装ReactJS.NET并导入教程代码,它就可以工作:
var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
Hello, world! I am a CommentBox.
</div>
);
}
});
ReactDOM.render(
<CommentBox />,
document.getElementById('content')
);
但是,假设我们现在出错了,并且在render函数中创建了另一个div,因此我们应该得到一个错误,因为我们不能有相邻的元素。然后我只会得到以下错误:
在console.log中,我得到以下错误,但对我没有帮助:
Invoices:841 GET http://localhost:55075/Scripts/React/InvoiceBuilder/App.jsx net::ERR_ABORTED
While if I used the standard Visual Studio template for React, the actual error would show very clearly.
Is this because I am not using Typescript? Or is there another way to get the nice error handling inside Visual Studio and the Chrome browser when dealing with React?
As my comment,
visual studio only focus on backend or desktop. Even reshapher cannot handle like this. I suggest use
vscode
for editing jsx like this
If you still want use visual studio instead of vscode, you can check lint js/jsx using flow, here documentation. It is use cmd/powershell/terminal to check validate code.
First install flow globaly, link
npm install -g flow
then on root of your project, run init flow by cmd/powershell:
flow init
last, put on the top your js (ex: tutorial.jsx):
// @flow
class CommentBox extends React.Component {
state = { data: this.props.initialData };
...
现在,您可以在cmd / powershell上运行以通过以下方式检查代码
flow status
然后看起来像这样:
坏消息是,还没有flow
Visual Studio的插件扩展,目前只有vscode。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句