Hi
A few months ago the answer would have been “You cannot use RNN with Expo unless you use the Bare workflow”
These days (with EAS) Expo’s tooling is much more powerful. Unfortunately things are more complicated as a result. Also, EAS is still in preview, so a lot of the documentation still talks about the managed workflow vs. the bare workflow when with EAS there is much less difference between those.
RNN is not compatible with Expo Go. However you can do basically the same thing with a Custom Dev Client. Expo Go has a predefined set of native code included and you cannot change that. A custom dev client is like Expo Go, except that instead of the predefined set of native code it uses whatever native code is needed by your app’s dependencies.
So, if you want to stick with RNN (and of course I would completely understand if you want to do that instead of ripping it out and replacing it with React Navigation) then you cannot use Expo Go, but you should still be able to use a Custom Dev Client.
Assuming you want to use a Custom Dev Client (to give you the Expo Go-like experience), there are two options:
- “Managed” workflow
- You do not have
android
and ios
subdirectories in your project.
- You would need a config plugin to tell Expo how to do whatever
npx rnn-link
does in a normal react native app.
- Bare workflow
- You do have
android
and ios
subdirectories in your project and you already have RNN correctly installed.
- I think this should basically just work.
About App.js
/index.js
etc.:
Expo does not require App.js
. In fact, if you use EAS to build a “managed” Expo app with expo-dev-client
installed then what it does on the build server is it runs expo prebuild
before starting the actual build. One of the things this does is it removes the “main” entry from package.json
and creates an index.js
at the top level (same location as package.json
) that basically just imports your App.js
and calls registerRootComponent()
.
So I think your index.js
should be fine and you should not need to worry about App.js
at all.
You are already asking RNN to do the registering, so I don’t think you need to call Expo’s registerRootComponent()
.
So I think the best way forward would be to install expo-dev-client
and try building your app using eas build
(or eas build --local
), like an Expo Bare Workflow app.
That may be good enough.
If you want something like the Managed Workflow you’ll need to make sure you do not have any custom changes in your android
/ios
directories, then remove those directories, and you’ll need a config plugin for handling the RNN installation. But that can come later.
As I said this is all a bit complicated, especially at the moment because Config Plugins are new. Ideally RNN will write a config plugin so you can just install it like any other dependency, as long as you build with EAS instead of expo build
.
I hope that clarifies things, but I’m not sure if I’ve explained things well enough.