在本机项目中使用@connect decorator进行捆绑错误

时间:2018-04-11 17:27:25

标签: reactjs react-native babeljs

当我尝试在设备上运行调试版本时,我的反应原生项目中运行的打包程序出现以下错误

: bundling failed: SyntaxError /app/js/screens/RootScreen.js: Unexpected token (27:0)
  25 |   };
  26 | }
> 27 | @connect(mapStateToProps, mapDispatchToProps)

我遵循了此博文https://medium.com/@ivanzotov/adding-es7-decorator-support-to-a-react-native-project-de537e958da0的建议,并将以下内容添加到我的.babelrc

{
  "presets": ["react-native-stage-0/decorator-support"]
}

但我仍然收到错误

1 个答案:

答案 0 :(得分:0)

根据Redux的最新自动生成的React Native Seed项目,预设似乎有不同的名称。将您的.babelrc更新为:

{
  "presets": ["babel-preset-react-native-stage-0/decorator-support"]
}