簡體   English   中英

{React jsx babel es6 webpack}我如何評論渲染(return(// || / ** /))?

[英]{ React jsx babel es6 webpack } How Can I Comment in render ( return ( // || /**/ ) )?

我上周開始了一個項目。 在回到我的團隊之前,我想評論我的代碼。

 /* 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
  • 反應ES6 JSX Babel
  • Bundler Webpack

順便說一句,因為Node v6已經出局了,我們還需要使用babel嗎?

你可以在jsx中發表評論,但你需要用大括號包裝它 -

{/* A JSX comment */}

{/* 
  Multi
  line
  comment
*/} 

請參閱React文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM