Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token at ::this._handlePageChange #1

Closed
vikamirror opened this issue Oct 15, 2016 · 6 comments
Closed

Unexpected token at ::this._handlePageChange #1

vikamirror opened this issue Oct 15, 2016 · 6 comments

Comments

@vikamirror
Copy link

A problem occurred at
04

I've update the version of react ("react": "^15.0.0") and react-dom ("react-dom": "^15.0.0")
What may I missing...?

@kirillDanshin
Copy link
Owner

hi.
this is es7 bind operator. so react version now isn't helpful info.
did you use babel and how you import the package?

@kirillDanshin
Copy link
Owner

@MirrorLin did you solve the issue?

@vikamirror
Copy link
Author

thanks for reply. I'm a beginner of react thus may ask question with wrong directions.
Since there was a problem with es7 bind operator, I replace the double colon with

"this.handlePageChange = this._handlePageChange.bind(this);"

However there's another problem occurred at

import Pagination from "paginorm";

on my npm, the error message was

ERROR in ./~/paginorm/dist/Pagination.js Module build failed: ReferenceError: [BABEL] D:\myProject\node_modules\paginorm\dist\Pagination.js: Using removed 5 option: D:\myProject\node_modules\paginorm.baberlrc.stage - Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets

I import the package by

npm i paginorm --save-dev

And here is my devDependencies in package.json

"babel-core": "^6.6.0",
"babel-loader": "^6.1.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-3": "^6.17.0",
"babel-standard": "^0.2.0",
"body-parser": "^1.15.0",
"bootstrap-less": "^3.3.8",
"concurrently": "^2.0.0",
"css-loader": "^0.23.1",
"es6-promise": "^3.2.1",
"es6-shim": "^0.35.1",
"eslint-config-google": "^0.7.0",
"eslint-config-standard": "^6.2.0",
"eslint-plugin-promise": "^3.3.0",
"eslint-plugin-react": "^6.4.1",
"eslint-plugin-standard": "^2.0.1",
"express": "^4.13.4",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"file-system": "^2.2.1",
"fs": "0.0.2",
"moment": "^2.13.0",
"multer": "^1.1.0",
"node-sass": "^3.4.2",
"paginorm": "^1.0.2",
"react": "^15.0.0",
"react-datetime": "^2.6.0",
"react-day-picker": "^2.2.0",
"react-dom": "^15.0.0",
"react-fa": "^4.1.2",
"react-hot-loader": "^1.3.0",
"react-router": "^2.8.1",
"redux": "^3.6.0",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"webpack-dev-middleware": "^1.5.1",
"webpack-dev-server": "^1.14.1",
"webpack-hot-middleware": "^2.9.1"

and here is my config in webpack.config.js

05

In my module.loaders, the "node_modules" has been excluded.

and my .babelrc

"presets" : ["es2015", "stage-3", "react"]

I've also read the issues here react-dnd/react-dnd#407
but nothing help.

Sorry for late reply, because I was busy with other bugs lately.

@kirillDanshin
Copy link
Owner

@MirrorLin please remove unnecessary

{
    test: /\.js$/,
    loader: 'babel'
},

The \.jsx?$ regexp equals that logic:

  1. match . and continue, else return false
  2. match j and continue, else return false
  3. match s and continue, else return false
  4. match x and check step 5, else if match $ (End Of Line) return true else return false
  5. match $ (EOL) and return true else return false

So it matches *.js and *.jsx files but not *.jsz, *asdf, *.jzz etc.

Also all that you need in the build you shoud --save (-S) not --save-dev (-D).

Please fix it and ping me here with the news.

@kirillDanshin
Copy link
Owner

@MirrorLin any news?

@ghost
Copy link

ghost commented Feb 25, 2017

In order to use the LHS bind operator '::' install
npm i -D babel-plugin-transform-function-bind
add 'transform-function-bind' to module/rules[test = /\.jsx?$/]/query/plugins
and use stage-1 for the corresponding presets (maybe you will need npm i -D babel-preset-stage-1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants