Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

When I init a react-native project, index.ios.js is created as project entry file.

Can I change this file's name and if so, how?

See Question&Answers more detail:os

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

1 Answer

When you start a react-native app you'll see this message output by the React Packager:

Running packager on port 8081

and then:

Looking for JS files in
   /Users/gbirman/gil/mapily 


React packager ready.

By this point, the packager has compiled your JS files and is serving them with the .js extension renamed to .bundle. For example, your index.io.js file is compiled and served from:

 http://localhost:8081/index.ios.bundle

If you added another file foo.js in the same directory as index.ios.js, the packager would serve it from:

 http://localhost:8081/foo.bundle

You can confirm this by opening that url in your browser.

Now to answer your question, your project has an iOS/AppDelegate.m file with the following line:

 jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];

... as you can see, it loads the index.ios.bundle. You can change the path/filename there to whatever you want, but it's probably best to stick with the recommended approach of naming your entry file index.io.js


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...