I am making use of react-router node module for routing in a react app. I am importing required modules as follows.
var React = require('react');
var Router = require('react-router');
var { Route, RouteHandler, Link } = Router;
// ... remaining code ...
But I am getting syntax error on line no. 3 i.e. var { Route, RouteHandler, Link } = Router;
Uncaught SyntaxError: Unexpected token {
Doing:
var {x,y} = {x:3,y:5};
Is called a destructuring assignment and is a new feature in JavaScript, it requires a new JavaScript runtime. This feature is not supported in NodeJS yet and not even in v8 yet (the JS engine JavaScript runs on). You can either assign it in 3 lines manually or use a tool like Traceur or Babel to compile your ES6 (new specification of EcmaScript) to ES5 (what node runs) code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With