Reputation: 347
hey guys having trouble with react-router, i keep getting this unexpected token you may need an appropriate loader to handle this file type on the line with <Router history={browserHistory}>
. im not sure what is going on here any help would be appreciated!
thanks
import React from 'react'
import ReactDOM from 'react-dom'
import { Router, Route, browserHistory } from 'react-router'
import Products from './Products'
import Home from './Home'
document.addEventListener('DOMContentLoaded', function() {
ReactDOM.render(
<Router history={browserHistory}>
<Route path="/" component={Home} />
<Route path="/" component={Products} />
</Router>, document.getElementById('mount')
);
});
webpack.config
var path = require('path');
var config = {
context: path.join(__dirname, 'src/js'),
entry: [
'./main.js',
],
output: {
path: path.join(__dirname, 'www'),
filename: 'bundle.js',
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel'],
},
],
},
resolve: {
root: [
path.join(__dirname, 'node_modules'),
],
},
};
module.exports = config;
.babelrc
{
"presets": ["es2015", "react"]
}
Upvotes: 0
Views: 293
Reputation: 35276
This isn't a React Router issue but instead is an issue with your JSX transpilation. Check your webpack.config.js file or your .babelrc file.
Upvotes: 1