Search code examples
androidreactjsreact-nativecreate-react-app

React Native Eject


i am a beginner to React native.

i read this on https://facebook.github.io/react-native/docs/getting-started that "If you used Expo CLI or Create React Native App to set up your project, you can preview your app on a device by scanning the QR code with the Expo app. In order to build and run your app on a device, you will need to eject and install the native code dependencies from the Getting Started guide"

can someone please explain these lines to me? Also, if we can see our app by using the "expo app" in our phone why do we need to eject it?


Solution

  • Not sure where you took the above quote...

    You will need to eject only if you use libraries with native code. Otherwise, it is highly recommended to use expo, it will make your life so much easier (some of the most significant ones are using expo libraries, sharing the app during development, building ipa and apk, getting updates to your users without rebuilding and submitting to the app stores).

    Both React Native documentation (https://facebook.github.io/react-native/docs/getting-started) and expo documentation (https://docs.expo.io/versions/latest/expokit/eject/) discuss that.

    Update - answering your question in the comment below.

    • Your question: "so there is no need to eject? i can build my whole app just by using expo? and can i publish my app through expo or do i have to eject it for publishing?"
    • answer: No need to eject unless you are using a package that is using native code. I am always trying to make an effort not to eject, if possible. If you stay with expo, you publish easily and you create ipa and apk easily. Without it you cannot publish (I read somewhere that it is possible, I don't know how to do it) and you need to build ipa and apk yourself. BTW, I have some problems ejecting, still trying to find out the solution. So right now, if I am starting a project that needs native packages, I am creating it with react-native init, and not within expo + ejecting. Did you try to publish with expo, and to create an apk or an ipa? If not, try it and see how great it is. Now create a project with react-native init and try to create an ipa and apk. You will understand what I mean.