React Native Eject but still being able to use React Native code - android

I've built some little prototypes within Expo with React Native but now I'm in the middle of a real project and I'm now discovering I will definitely need to eject my project for certain components to work.
My question is, once I eject, can I ever write React Native Code without having to init again which I assume will erase any changes I made at the native level?
Any techniques or references are appreciated.

Your question is a bit confusing, so I'll try to answer it as best as I can.
TL;DR: You will be able to write React Native code once you eject from Expo without having to use expo-cli init.
Expo Init
When you say "...can I ever write React Native Code without having to init again..." I assume you mean exp init (or expo-cli init) as opposed to react-native init. These commands merely initialize the project for you, so you shouldn't need to run them more than once.
For more information about how they differ from one another I recommend this GitHub issue thread.
Expo Eject
Expo allows you to eject your pure-JS project from the Expo iOS/Android clients, providing you with native projects that can be opened and built with Xcode and Android Studio. Those projects will have dependencies on ExpoKit, so everything you already built will keep working as it did before.
This means that when you eject your app you'll be writing React Native code outside of the Expo client environment, meaning you'll have access to the native code for Android and iOS. Even so, you will write normal React Native code (Javascript and JSX).
Also once you eject, Expo will add Expo Kit to your project which will give you access to some of Expo's features. For more information check their docs.

Related

What is the difference between react-native cli and Expo with Bare workflow? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
The community reviewed whether to reopen this question 8 months ago and left it closed:
Needs more focus Update the question so it focuses on one problem only by editing this post.
Improve this question
I am going to build a very big application with multiple complex functionalities. but I am stuck on bellow points -
What is the difference between react-native cli and Expo with Bare workflow?
what Should I include in my project and why?
is expo created by facebook?
What is the difference between react-native-cli and Expo with Bare workflow?
Expo with Bare workflow is basically a react-native-cli app that is already preconfigured in order to support most of the Expo packages (here are the supported API in the bare workflow: https://docs.expo.io/bare/unimodules-full-list/ ). With a bare app, you meet halfway between expo managed and react-native-cli. The main configuration that is already made when initiating a bare app is the setting up of the react-native-unimodules package which is provided by the Expo team (https://github.com/expo/expo/tree/master/packages/react-native-unimodules).
In a bare app, you need Xcode and Android studio just as for a plain react-native-cli app.
In the bare app, you can install most of the Expo packages but you have to follow the specific installation instructions for the bare workflow (e.g: install with npm, linking, pod install, etc...).
Expo bare apps have to be started with the react-native command, they do not use the expo cli after their creation.
Most of the convenient features of expo managed app are missing in the bare workflow but Expo is working on integrating most of them over time.
what Should I include in my project and why?
What you should include depends on your needs. A strong analysis of the final goal of the project will let you decide between managed workflow on one side and bare workflow / react-native-cli on the other side.
The choice between bare workflow and react-native-cli is simpler as they are basically the same but bare workflow has some extra configurations already made.
is expo created by Facebook?
No, but Expo is recognized by them as a really useful tool for react-native development. (that's why expo is one way of creating app according to the official react-native documentation).
Expo is written on top of react-native to overcome the issues and challenges that developers face in the development, When it offers some features then it also has some limitations as well.
What is the difference between react-native CLI and Expo with Bare workflow?
The key difference between these two is the management of different react-native packages.
Expo holds almost(not all) everything that react-native has so instead of installing and managing a module separately it offers everything within the expo, So you don't need to take care separate native modules as and expo will do for you but expo has a limitation that if something new launched in react-native until expo adds it in expo you can't use it.
Another limitation is you can't use a library that requires linking because of expo manages this thing for you and you have a boundary to use libraries that expo supports(Managed workflow).
Expo manages the build system for you, So you don't have to use Android-studio or Xcode for making builds.
It has a limitation about the size, So your app can't be below(Android 2MB, IOS 25MB) to this even if a single screen app.
Limitations with managed workflow
Not all iOS and Android APIs are available.
The SDK doesn't support all types of background code execution
If you need to keep your app size extremely lean, the managed workflow may not be the best choice.
Native libraries to integrate with proprietary services are usually not included in the SDK.
The only supported push notification service is the Expo notification service.
The minimum supported OS versions are Android 5+ and iOS 10+.
Free builds can sometimes be queued.
Bare workflow
Bare workflow gives you more control over linking native libraries and managing builds.
On the other hand with react-native CLI you have the freedom to install anything and size also depends on your app.
In the bare workflow we have full access to the underlying native projects and any native code. It's a "bare" native project with React Native and one or more packages from the Expo SDK installed. Anything that you can do in a native project is possible here.
In the bare workflow, the developer has complete control, along with the complexity that comes with that. You can use most APIs in the Expo SDK, but the build service and easy configuration with app.json are not yet supported. You can refer to tutorials and guides that are oriented towards native iOS and Android apps and React Native for alternatives.
Limitations with bare workflow
Build service only works in the managed workflow.
Configuration must be done on each native project rather than once with app.json
Here is a comparison between these.
https://docs.expo.io/introduction/managed-vs-bare/?redirected#workflow-comparison
What Should I include in my project and why?
It depends, You have to figure it out everything that you wanted to use inside the app is been supported on the expo, If everything(Every Native Module) is available then it's okay to use expo otherwise if you have to eject in between the development it's a painful process.
Is the expo created by Facebook?
Officially not, but it has the support of some core developers of react-native.
Here is a link that offers a comparison between these two.
What is the difference between Expo CLI and React Native CLI?
I am writing this answer after using expo bare workflow for 3months .
I will recommend to use react-native cli over expo bare workflow because of bellow regions.
Expo bare workflow is not developed by facebook team , so when there is a new update in RN Cli, expo takes 1-2 months to add in its workflow .
You can not control the size of app because expo includes pre included library in SDK. (minimum prod build starts from 29MB-38MB)
App deployment and coding styling is same in both bare-work flow RN Cli, then why not use React native Cli.
Ejecting expo in middle of ongoing project is really painful process.
you may (very rarely) face compatibility issue with external lib.
upgrading expo is also painful for larger code base app.
When to use expo bare workflow
if you have a really good understanding on react native architecture and you know the depth technical requirements of project. Also you should aware of available expo libraries and how many things you are going to use in your project and you are not bothered about app size too.
Note : expect above points you wont see any difference between RN cli and bare work flow while coding .

react-native init versus Expo for new React Native project?

I am completely new to React Native and I would like to develop my first RN app. I have experience with React and building iOS apps with Swift, but I have never tried React Native.
I see that there are two main ways of creating a new app, either with react-native init or through Expo. Which is the preferred toolchain for someone of my experience? Can somebody explain the tradeoffs between the two?
If you are just trying to learn, I would suggest you to use the cli.
The main difference between react-native init and expo is that you cant add native modules and can't use packages with native language that require linking. Overall if you are creating a small project that doesn't require functionalities that the cli, go for expo. But if you are builidng a decently large project or if you are just trying to learn your ways around react native, I would chose the cli. IMHO

React Native Android to iOS migration

I have an Android app built from scratch using React Native. Can I migrate the same app to iOS? If so, how tough will it be?
The Android app is already built and working fine.
If the app is done in React Native, you could build it using Xcode, of course you need a Mac, https://facebook.github.io/react-native/docs/getting-started#xcode.
You can also try from command line
react-native run-ios
Remember that you still need to install Xcode and the tools needed to build on the simulator or your device.
Also remember that you might have to do some changes in your code, not always the code for android works in iOS, moreover if you are using native modules done by you or from a library.
A project written in react-native should, by default, work on iOS.
Normally tho, every package you have used, some styles still differs from each other from platform, some things are avaiable to do on Android and not on iOS, some things are avaiable on iOS and not on Android.
Some packages needs linking. Some needs additional steps to run on iOS changing some datas/informations using xcode. (like deep linking).
On react-native 0.60 you need to install the pods manually as it's not done by the autolinking, there are a lot things to check and it may not be automatic for the majority of the cases

Do we get the pure native code file after packing the application created with react native?

I am new to React Native and first of all it is the best framework for building cross platform applications using the JSX.
Few questions that are stinging me to know that:
When we run the app created with react native, does it convert the
Javascript code into native Java or Objective-C and then this native
code is executed in the phone to run the app and get the output?
When we pack the application created with the React Native, does we get the pure compiled native code in this file i-e .apk or ipa(same as created with pure Java or Objective-C)?
I am using the React Native application development method Native Code development(Android Studio + React Native + Virtual Device - followed the documentation on the React Native site).
Question #1 is already asked on the stack overflow but i am failed to understand because i am beginner in react native.
Please can some one answer my questions in simple and easy explanation?
Again, please easy words explanation !!!
No, the React Native framework is native code, but your Javascript code is included in the build as Javascript and interpreted at runtime. This is how you're able to debug code changes without rebuilding your app, and use services like CodePush to deploy new Javascript bundles to already deployed binaries.
Yes, react native is essentially a JS library built on top of Java and Objective-C, and compiles to native code.

React-Native and Expo: Any different between create-react-native-app and react-native init

I need some clarify of the difference between create-react-native-app then detached and react-native init.
I understand that the former one will create an app based on the expo and later require detached to expose the native code of android and iOS for native code implementation. The react-native init will generate the native code at the same time.
Are there any difference after detach from expo after created from create-react-native-app command, compared with react-native init?
The only significant difference is that you still depend on the Expo SDK. From the website:
We call this "detaching" because you still depend on the Expo SDK, but your project no longer lives inside the standard Expo client. You control the native projects, including configuring and building them yourself.

Categories

Resources