Reputation: 2495
I am trying to create routes for my React application with react-router-component. But when I build my project with webpack, I get the error:
ERROR in ./app/js/client.jsx
Module build failed: Error: Parse Error: Line 22: Unexpected token <
The routes are in my client.jsx file, which looks like this:
'use strict';
var React = require('react');
var Router = require('react-router-component');
var Locations = Router.Locations;
var Location = Router.Location;
var {MainPage} = require('./components/views/app.jsx');
var App = React.createClass({
render: function() {
return (
<Locations>
<Location path="/" handler={MainPage} />
</Locations>
)
}
})
React.render(React.createElement(App), document.body)
I'm not sure what I'm doing wrong here. Any help would be appreciated. Let me know if you need more info. Thanks!
Edit: my webpack configuration looks like this:
webpack: {
client: {
entry: __dirname + '/app/js/client.jsx',
output: {
path: 'build/',
file: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx$/,
loader:'jsx-loader'
}]
}
},
test: {
entry: __dirname + '/test/client/test.js',
output: {
path: 'test/client/',
file: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx$/,
loader:'jsx-loader'
}]
}
},
karma_test: {
entry: __dirname + '/test/karma_tests/test_entry.js',
output: {
path: 'test/karma_tests/',
file: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx$/,
loader:'jsx-loader'
}]
},
background: true
}
},
You can see the full project so far here: https://github.com/mrbgit/short-stories/tree/add-category-age
Upvotes: 3
Views: 2431
Reputation: 3485
Don't use destructuring for the MainPage
variable since that file is only exporting the React class. It should look like this
var MainPage = require('./components/views/app.jsx');
Upvotes: 1