{React jsx babel es6 webpack}我如何评论渲染(返回(// || / ** /))?

上周我开始了一个项目。 回到我的团队之前,我想评论我的代码。

/* Just for the Syntax outlook */ class Foo extends React.Components { constructor(props) { super(props); } render() { return ( <div className='bar'> /* <p> cannot commit!!!! </p> ** Following will throw error when bundled with webpack */ // This throws error as well. <div> ) } } 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script> 

代码可能看起来像评论正在工作,但目前JSbin的设置没有在ES6上设置。 当你使用jsx通过webpack运行它时,会抛出一个错误。

这里是下面的堆栈

  • 节点v6.0.0
  • React ES6 JSX Babel
  • Bundler Webpack

顺便说一句,因为节点v6出来了,我们还需要使用babel吗?

你可以在jsx中发表评论,但是你需要用大括号包装它 –

 {/* A JSX comment */} {/* Multi line comment */} 

请参阅React文档