reactjs - Error parsing Es6 jsx to js React -
i trying work react. have next code :
index.js
var btn = require('./components/btn.jsx'); var app = { // application constructor initialize: function() { console.log("here me"); reactdom.render(<btn>, document.getelementbyid('app')) }, ondeviceready: function() { this.receivedevent('deviceready'); }, }; app.initialize();
i have next node_modules instaled:
- babel
- babel-plugin-transform-react-jsx
- babel-preset-env
- babel-cli
- babel-preset-env
- babel-preset-es2017
- babel-preset-react
mi .babelrc
{ "presets": ["env"] }
when run comand whath , compile jsx js have next
$ babel --presets env js/src --watch --out-dir js/dist syntaxerror: js/src/index.js: unexpected token (10:24) 8 | initialize: function() { 9 | console.log("here me"); > 10 | reactdom.render(<btn/>, document.getelementbyid('app')) | ^ 11 | }, 12 | 13 | ondeviceready: function() {
i find , try lot of things don't undestand happen, in each tutorial see sintax correct , works good. hope can stupid , can't found it. can explain me can do? or how.
since have babel-preset-react
, try adding .babelrc {"presets": ["react", "es2017"], }
check link format .babelrc
Comments
Post a Comment