在本机站点上查看教程时出现本机错误 [英] react-native error when going over tutorial at react native site

查看:37
本文介绍了在本机站点上查看教程时出现本机错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个完整的初学者,所以请提供一些解释.

我正在

解决方案

我能看到的是,您所关注的教程是针对 RN 0.19 的,而最新的稳定版本是 0.47.这些代码中的所有示例代码都使用旧的 ES5 语法和 ES6/ES2015

中基于类的较新的语法

首先,请确保您遵循的是最新的教程版本及其代码.你可以从这里做到这一点.https://facebook.github.io/react-native/docs/tutorial.html我可以看到的错误与 babel 转换有关,可能归因于较新版本的 React Native 以及运行较旧代码的较新版本的 React.因此,您可能应该从较新的教程开始,然后从那里开始学习.此外,react-native-cli 的使用现在已弃用.您应该使用 create-react-native-app 来启动一个新项目.这一切都在文档中.

希望有帮助!

I am a complete beginner, so please provide some explanation.

I am following react-native tutorial at https://facebook.github.io/react-native/releases/0.19/docs/tutorial.html

I run command to init project, I just call it Movies instead of AwesomeProject as the tutorial explains.

Then I copied the complete code from the bottom of the tutorial into my index.ios.js, save the project and refreshed emulator and I get this error

error: bundling failed: "TransformError:
/Users/dinob/reactnativework/Movies/index.ios.js: 
Unexpected token ) (While processing preset:
\"/Users/dinob/reactnativework/Movies/node_modules/
babel-preset-react-native/index.js\")"

React-native-cli: 2.0.1 React-native: 0.47.1 React: 16.0.0-beta.2

解决方案

What I can see is, the tutorial you're following is for RN 0.19 while the newest stable version is 0.47. All the examples codes inside those use the older ES5 syntax and the not newer class based syntax that came in ES6/ES2015

Firstly, please make sure you're following the newest tutorial version and its code. You can do that from here. https://facebook.github.io/react-native/docs/tutorial.html The error which I can see there is related to a babel transform and could possibly be attributed to newer version of React Native plus a newer version of React running older code. So you should probably start with a newer tutorial and take it from there. Also, the use of react-native-cli is now depreciated. You should use create-react-native-app to start a new project. It's all in the docs.

Hope it helps!

这篇关于在本机站点上查看教程时出现本机错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆