I would like to install NetInfo on my expo project, so I saw that I would run
expo install @react-native-community/netinfo. Great!
But now I would like to understand how it works. Indeed, the @react-native-community/netinfo package explains that to install it on a classic react-native application, developers have to modify native code. I don’t see any app.plugin.json file to add plugins to Expo in the codebase, so I don’t understand how Expo works under the wood to install this native library.
Is it ok if I install it with
yarn add @react-native-community/netinfo?
If you’re using
expo build:ios to build the app, or if you’re running the app in Expo Go then that native code is already included. Every Expo app built using the above “classic” build system includes that code. That is one reason that apps built that way are bigger than they need to be.
If you build with EAS Build (where
app.plugin.js/config plugins come into the picture), then the native code is only included if you install the dependency.
The only difference between
expo install and
yarn add is that
expo knows which version is compatible with the native code included in a particular Expo SDK version. If you use
yarn add @react-native-community/netinfo there’s a possibility that you’ll get a version that is too new and incompatible with the native code included in the Expo SDK.