I want to use the new ES6 React classes that was introduced with React v0.13, but I am unable to get it to compile correctly. Say I have the following React component defined in the new class syntax:
(function() {
'use strict';
import React from 'react';
class _UserDashboard extends React.Component {
render() {
return(
<div className="user-dashboard">
<Books />
</div>
);
}
}
export const UserDashboard = React.createClass(_UserDashboard.prototype);
}());
The trouble I run into here is that at compile time using Grunt and Browserify and a Reactify transform, Reactify throws an error when it encounters the import keyword:
ReactifyError: /Users/****/Sites/***/assets/js/components/UserDashboard.jsx: Parse Error: Line 7: Unexpected reserved word while parsing file: /Users/****/Sites/****/assets/js/components/UserDashboard.jsx
The problem here seems to have to do with Reactify's use of react-tools, see here and here. But I'm not sure if it is possible to enable the es6module option within Reactify yet.
I tried these two variations to no avail:
...
transform: [[ 'reactify', {'es6module': true} ]]
...
and
...
transform: [[ 'reactify', {'es6':true, 'es6module':true} ]]
...
Does anyone know how this can be done?