On the Writing of react-native entry File

after using a react-native init project, its entry file is written as follows

import { AppRegistry } from "react-native";
import App from "./App";

AppRegistry.registerComponent("app", () => App);

this is normal and conforms to my understanding of react. But today, I can see in a project that it can be written like this:

import App from "./src/app";

const app = new App();
The export in

app.js is not a react component, but a normal function. project address

I don"t understand why this piece can be written in this way., new App () has become an object.

Mar.18,2021

suggests flipping through the historical version. It should be
startApp which also supports this kind of functional call rn . This hook function


Under the

src/screens/index.js file, there is a function called registerScreens , which calls Navigation.registerComponent , while Navigation.registerComponent returns a generationWrapper and executes AppRegistry.registerComponent to register your screen component, so when new App , it actually executes AppRegistry.registerComponent .

related source code: registerScreen

Menu