user4973992
user4973992

Reputation:

SyntaxError in npm run build / React

Halfway through a React tutorial series and getting an error at the end of mapStateToProps. My code is the same as in the tutorial as far as I can tell.

In Command Line:

> npm run build 
> SyntaxError: /home/jake/web/flashcards/src/components/App.js: Unexpected token (5:22) while parsing file: /home/jake/web/flashcards/src/components/App.js

This is the App.js:

import React from 'react'; 
import Sidebar from './Sidebar';
import {connect} from 'react-redux';

const mapStateToProps (props, {params:{deckId}}) => ({
    deckId
});

const App = ({deckId, children}) => {
    return(<div className ='app'>
        <Sidebar />
        <h1> Deck {deckId} </h1>
             {children}
        </div>);
};

export default connect(mapStateToProps)(App);

my package.json:

{
  "name": "flashcards",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "watchify src/app.js -o public/bundle.js -t [ babelify --presets [ react es2015 ] ]",
    "server": "cd public; live-server --port=1236 --entry-file=index.html"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babelify": "^7.3.0",
    "live-server": "^1.2.0",
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "react-redux": "^5.0.4",
    "react-router": "^3.0.2",
    "react-router-redux": "^4.0.8",
    "redux": "^3.6.0",
    "watchify": "^3.9.0"
  }
}

Upvotes: 0

Views: 111

Answers (2)

Pr3ds
Pr3ds

Reputation: 358

initializer in const declaration

const mapStateToProps = 
                      ^^

Upvotes: 1

Patrick Hund
Patrick Hund

Reputation: 20266

Missing equals sign:

const mapStateToProps = (props, {params:{deckId}}) => ({
    deckId
});

Upvotes: 2

Related Questions