如何为React Native应用定义入口点 [英] How to define entry point for react native app

查看:150
本文介绍了如何为React Native应用定义入口点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用react native,并使用create-react-native-app创建了一个基本应用.

I'm just getting started with react native and have created a base app with create-react-native-app.

我进行了一些重组,并创建了一些新文件夹,并将App.js重命名为Home.js.我修改了app.json以包含引用新的Home.js文件的入口点.当我加载该应用程序时,什么也没有发生.没有错误,它只停留在博览会屏幕上.

I did some restructuring and made a few new folders and renamed the App.js to Home.js. I modified the app.json to contain an entry point that references the new Home.js file. When I load the app, nothing happens. There's no error, it just stays on the expo screen.

.
 -components
 -screens
    -Home
        Home.js
 -config
 -node_modules
 -tests
 app.json

app.json文件:

app.json file:

{
  "expo": {
    "sdkVersion" : "23.0.0",
    "entryPoint" : "./screens/Home/Home.js"
  }
}

您如何定义应用的入口点?

How do you define the entry point of the app?

推荐答案

如果使用的是Expo,则必须在app.json文件中指定入口点,如下所示:

if you are using Expo, you have to specify the entrypoint in your app.json file like this:

{
  "expo": {
    "entryPoint": "./src/app/index.js"
  }
}

然后,在该文件中,您需要向Expo.registerRootComponent(YOUR_MAIN_APP_COMPONENT)

then, inside that file you need to register the app with Expo.registerRootComponent(YOUR_MAIN_APP_COMPONENT)

import Expo from 'expo'
...

class App extends Component {
  ...
}

export default Expo.registerRootComponent(App);

这样,您可以在任意位置添加条目文件.

this way you can add your entry file wherever you want.

这篇关于如何为React Native应用定义入口点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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