ReactNative Eject Explained

后端 未结 2 846
孤街浪徒
孤街浪徒 2020-12-30 20:24

I literally started reading about ReactNative an hour ago and am reading this git readme https://github.com/react-community/create-react-native-app/blob/master/react-native-

相关标签:
2条回答
  • 2020-12-30 20:45

    My understanding is that when you run the "create-react-native-app" (or "expo init" now) you are basically adding the Expo library on top of React Native.

    I think the main reason for using Expo is to get your app up and running quickly. I think the main reason to eject is that eventually you might need to do more complicated customization with native code and need more control, etc. Here is a better explanation of Expo vs React Native CLI to bootstrap your app:

    https://levelup.gitconnected.com/expo-vs-react-native-cli-a-guide-to-bootstrapping-new-react-native-apps-6f0fcafee58f

    When you eject you are returning to the same state as if you did not use Expo to setup your app (native ios/android projects will be generated, etc.)

    Here are a few other links that helped me understand: http://www.reactnativeexpress.com/environment

    https://docs.expo.io/versions/latest/expokit/eject/

    0 讨论(0)
  • 2020-12-30 20:52

    Summary

    If you created an app using create-react-native-app MyApp, ejecting your app gets your app to be the same as if you created your project using react-native init MyApp

    aka

    create-react-native-app MyApp > make changes to app > eject app

    is roughly equivalent to

    react-native init MyApp > make changes to app

    More Details

    What's the difference between create-react-native-app MyApp and react-native init MyApp?

    Quick start vs. Full scale development

    The philosophy behind create-react-native-app is:

    • Minimal "Time to Hello World": Create React Native App should reduce the setup time it takes to try building a mobile app to the absolute minimum, ideally on par with React web development (especially as seen with Create React App).
    • Develop on Your Device: It should be easy to develop on a physical device when you want to test how your app feels and responds to inputs.
    • One Build Tool: If you just want to get started with React Native, you shouldn't need to install Xcode, Android Studio, NDKs, or mess with environment variables.
    • No Lock-In: You can always "eject" to your own build setup if you need to write custom native code or modify how your app is built.

    Essentially, create-react-native-app lets you get up and running quickly without having to a do a lot of (or any) configuration. In order to do this, it hides a lot of details from you.

    If you want to create a serious app, you need to set up a real development environment. You can do this from scratch by running react-native init <project-name>. If you started with a react native project using create-react-native-app, you can get to this same place by "ejecting" your app

    More details from the official documentation about getting started with React Native can be found here.

    0 讨论(0)
提交回复
热议问题