简体   繁体   English

如何正确更改 Expo 入口点?

[英]How to change Expo entry point properly?

I want to change entry point of my expo app.我想更改我的 expo 应用程序的入口点。 I have tried these simple steps:我已经尝试了这些简单的步骤:

First of all, I have created a simple expo project.首先,我创建了一个简单的 expo 项目。

$ expo init test
$ cd test
$ rm App.js
$ mkdir src
$ touch src/App.js

I have changed app.json of my expo based app as follows我已更改基于 expo 的应用程序的 app.json 如下

{
    "expo": {
        ...,
        entryPoint: "./src/App.js",
        ...
    }
}

Then i have filled the App.js as folows然后我填写了 App.js 如下

import React from "react";
import { Text } from "react-native";

export default () => <Text>Hello World</Text>;

However, the first trial have been failed.然而,第一次审判失败了。 It have shown only splash screen.它只显示了启动画面。

Then i have edited the App.js as follows:然后我编辑了 App.js 如下:

import React from "react";
import { Text } from "react-native";
import { registerRootComponent } from "expo";

const App = () => <Text>Hello World</Text>;

registerRootComponent(App);

I have seen "Hello World" text in the screen.我在屏幕上看到了“Hello World”文本。 However, hotreloading have not been working.但是,hotreloading 一直没有工作。 Then i have modified main entry in package.json然后我修改了 package.json 中的主要条目

"main": "./src/App.js",

In this way hot reloading is working in second save action.这样,热重载在第二次保存动作中起作用。

I am wondering我想知道

  • How can i solve hot reloading problem (in first save action)?我如何解决热重载问题(在第一次保存操作中)?
  • What is the difference between app.json's entryPoint and package.json's main field? app.json 的 entryPoint 和 package.json 的 main 字段有什么区别?

I suggest you read this article:我建议你阅读这篇文章:

https://docs.expo.dev/versions/latest/sdk/register-root-component/#what-if-i-want-to-name-my https://docs.expo.dev/versions/latest/sdk/register-root-component/#what-if-i-want-to-name-my

and be sure you restarted your whole dev process并确保您重新启动了整个开发过程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM