Unexpected ReactJS Token) Safari only

I SyntaxError: Unexpected token ")"only get in Safari - this code works in any other browser.

I use gulpto compile my files as follows:

browserify(componentPath + "app.jsx")
    .transform(reactify)
    .transform(babelify)
    .bundle()
    .pipe(source('app.js'))
    .pipe(gulp.dest(buildPath));

A syntax error highlights the following:

return React.createElement(If, {
     condition: !_.isEmpty(title)
 }, React.createElement("div", {
     className: "row wrapper border-bottom white-bg page-heading"
 }, React.createElement("div", {
     className: "col-lg-9"
 }, React.createElement("h2", null, title || 'Untitled'), React.createElement("ol", {
     className: "breadcrumb"
 }, React.createElement("li", null, React.createElement("a", {
     onClick: () => self.history.pushState(null, home)
 }, "Home")), links.map(function(link, index) {
     var url = link.url;

     return React.createElement("li", {
         onClick: () => self.history.pushState(null, url),
         key: url,
         className: "ptr-click"
     }, index == links.length - 1 ? React.createElement("strong", null, link.title || 'Untitled') : link.title);
 })))));

I commented on the entire section to see if it is this particular block of code, but then the error referred to another block exactly the same React.createElement.

+4
source share
1 answer

Given mattclemens , Safari does not currently act as an arrow. So I updated my gulpscript to:

browserify(componentPath + "app.jsx")
    .transform(reactify)
    .transform(babelify, {presets: ["es2015", "react"]})
    .bundle()
    .pipe(source('app.js'))
    .pipe(gulp.dest(buildPath));

Of course, do not forget to set the presets:

npm install babel-preset-es2015 babel-preset-react

, Safari:)

+2

Source: https://habr.com/ru/post/1617129/


All Articles