如何定义反应原生应用程序的入口点 [英] How to define entry point for react native app

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

问题描述

我刚刚开始使用 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.

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

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