I am trying to get started building a site in ReactJS. However, when I tried to put my JS in a separate file, I started getting this error: \"Uncaught SyntaxError: Unexpecte
JSTransform is deprecated , please use babel instead.
<script type="text/babel" src="./lander.js"></script>
If you are getting an error like this :
SyntaxError: embedded: Unexpected token (107:9) 105
It could be you are missing a curly bracket
The code you have is correct. JSX code needs to be compiled to JS:
http://facebook.github.io/react/jsx-compiler.html
Add type="text/babel"
to the script that includes the .jsx file and add this: <script src="https://npmcdn.com/babel-core@5.8.38/browser.min.js"></script>
I have the same issue with you and I have change something in my server
you might try this
const root = require("path").join(__dirname, "./build");
app.use(express.static(root));
app.get("*", (req, res) => {
res.sendFile("index.html", { root });
});
Try adding in webpack, it solved the similar issue in my project. Specially the "presets" part.
module: {
loaders: [
{
test: /\.jsx?/,
include: APP_DIR,
loader: 'babel',
query :{
presets:['react','es2015']
}
},