delete
delete

Reputation: 19148

Unexpected token on "export default const"

I have two different reat-native projects with exactly the same version of libraries.

But the newest one failes on "export default const", the other one not.

What is the difference between both calls?

The first one compiles correctly and is already in the app stores with the following code:

export default const result = [...]

The second one has the same package.json and failes on the same code "unexpected token (1:15) -> the position 15 is after the "default".

This is the used package.json:

{
  "name": "rn_simpleorm",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start"
  },
  "dependencies": {
    "react": "15.3.2",
    "react-native": "^0.32.0"
  },
  "jest": {
    "preset": "jest-react-native",
    "modulePathIgnorePatterns": [
      "node_modules/react-native/node_modules/"
    ]
  },
  "devDependencies": {
    "babel-jest": "^15.0.0",
    "babel-preset-react-native": "^1.9.0",
    "jest": "^15.1.1",
    "jest-react-native": "^15.0.0",
    "react-test-renderer": "^15.3.1"
  }

}

Upvotes: 20

Views: 22464

Answers (1)

Joe Attardi
Joe Attardi

Reputation: 4521

You are exporting a value. const result = isn't a value. What you want is either:

export default [...];

or:

const result = [...];
export default result;

Upvotes: 38

Related Questions