简体   繁体   中英

How to change Expo entry point properly?

I want to change entry point of my expo app. I have tried these simple steps:

First of all, I have created a simple expo project.

$ 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": {
        ...,
        entryPoint: "./src/App.js",
        ...
    }
}

Then i have filled the App.js as folows

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:

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. However, hotreloading have not been working. Then i have modified main entry in 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?

I suggest you read this article:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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