我有两个不同的RET原生项目,它们的库版本完全相同.

但最新的一个在"导出默认常量"上失败,另一个则没有.

两个电话的区别是什么?

第一个已正确编译,并已在应用store 中使用以下代码:

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".

这是用过的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"
  }

}

推荐答案

您正在导出一个值.const result =不是一个值.你想要的是:

export default [...];

或者:

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

React-native相关问答推荐

Reaction-原生NavBottom设计背景

如何在Reaction本地日历中 Select 年份?

防止 React Native 在上下文值更改时重新安装组件

根据搜索字符串中的每个字母过滤数组

如何在 react-navigation v6 中更改标题高度

无法在 M1 zsh 上运行 adb segmentation fault adb

使用 React Native 下载数据文件以供离线使用

如何获取 iOS 版本?

如何为我的 React Native Android 应用程序使用 Crashlytics?

ReactNative 0.43-rc.2 FlatList -- 试图获取超出范围索引 0 的框架

TouchableOpacity 作为 ListView 中的 Item 仅在 TextInput 失go 焦点后做出响应

使用 create-react-native-app 创建了一个应用程序,如何将其发布到 Google Play store ?

如何在 React Native 中按住以 Select 文本

自定义原生基础的选项卡

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

React Native vs Swift/Objective-C/Java Native

React Native onLayout 与 React Hooks

React Native - 为什么执行这个函数?

如何在 react native 中将数组保存在异步存储中?

React-Native 获取 XML 数据