talyssonoc / react-laravel

Package for using ReactJS with Laravel
896 stars 90 forks source link

Syntax error #71

Closed inkong closed 8 years ago

inkong commented 8 years ago

HI

Do you have any idea why I'm getting this error below when trying to add this in my view @react_component('Message', [ 'name' => 'Hue' ])

V8Js::compileString():18903: SyntaxError: Unexpected token <

markvital commented 8 years ago

+1 have similar issue, which is hard to troubleshoot

francoislefebvre commented 8 years ago

Same here. Anyone with a solution?

talyssonoc commented 8 years ago

@markvital @francoislefebvre this lib does not compile JSX, I recommend compile it separately with Babel.

francoislefebvre commented 8 years ago

Thanks.

Solution :

$ npm install --save-dev gulp-babel
$ npm install --save-dev babel-plugin-transform-react-jsx

gulpfile.js

var gulp = require("gulp");
var babel = require("gulp-babel");

gulp.task("default", function () {
  return gulp.src("resources/jsx/*")
    .pipe(babel({
            plugins: ['transform-react-jsx']
        }))
    .pipe(gulp.dest("public/js"));
});