Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
609 views
in Technique[技术] by (71.8m points)

react-native error when going over tutorial at react native site

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

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...