reactjs - React Browserify Babel - Unexpected token error -


i'm attempting bundle dependencies using browserify via command line. command completes without error - can tell, loading page results in 'unexpected token <' error.

here's command i'm using:

browserify -t [ babelify --presets [ es2015 react ] ] main.js -o bundle.js 

main.js

'use strict'; var react = require('react'); var reactdom = require('react-dom'); var $ = require('jquery'); 

jsx:

'use strict';  var react = require('react'); var reactdom = require('react-dom'); var $ = require('jquery');  class sidenav extends react.component{ constructor(props) {     super(props);     this.state = {items: new array()};  } componentdidmount() {     $.ajax({         url:"/json/sidenav.json",         datatype: "json",         cache: false,         success: function(data) {             this.setstate({items: data});         }.bind(this)     }); } render() {      var items = [];      this.state.items.foreach((item) => {          items.push(<navitem title={item.title} link={item.link} active={item.active} />);      });     return (         <ul classname="nav nav-sidebar">         {items}         </ul>     );   }  } class navitem extends react.component{     render() {         var clazz = this.props.active ? 'active' : '';         var link = this.props.active ?                  <a href="#">{this.props.title} <span classname="sr-only">(current)</span></a> :                 <a href={this.props.link}>{this.props.title}</a>         return (             <li classname={clazz}>{link}</li>         );     } }  reactdom.render(     <sidenav/>,      document.getelementbyid('sidenav') ); 

huge arnehugo! realized including jsx in .hmtl meant wasn't getting transpiled. moving main.js , fixing typo fixed problem.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -