"Uncaught SyntaxError: Unexpected token { " using Reactify
Ad
I am following a tutorial to create a FixedDataTable with React. However, I have some issues getting the following line to work in my jsx-file:
const {Table, Column, Cell} = require('fixed-data-table');
which gives the error (in Chrome):
Uncaught SyntaxError: Unexpected token {
I am using browserify and reactify to transform my jsx code to javascript. Other lines using require work fine.
I am quite new to JavaScript and React and would appreciate any suggestions to solve hte problem.
Ad
Answer
Ad
The issue was as pointed out in the comments that the ES6 option in reactify wasn't activated. I edited the following row in my gulpfile:
transform: [
[ 'reactify', {'es6': true} ]
],
And then it worked. As a workaround I found out that you also can do:
var FixedDataTable = require('fixed-data-table');
var Table = FixedDataTable.Table;
var Column = FixedDataTable.Column;
instead of
var {Table, Column, Cell} = require('fixed-data-table');
Ad
source: stackoverflow.com
Related Questions
Ad
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad