
上QQ阅读APP看书,第一时间看更新
Setting up JSX
To be able to use JSX, we need to install the React plugin for Babel. It will then compile JSX into proper calls to the React API. Firstly, we need to install the babel-preset-react package:
npm install --save-dev babel-preset-react
In addition to installing the preset, we also need to tell Babel to use it. Edit .babelrc, find the "presets" property, and add "react" to the array. It should look like this now:
{ "presets":[ "es2015", "react" ], "plugins": [ "transform-object-rest-spread" ] }