Using Expo just to make development faster

Hi! Our team decided to write a new mobile app on ReactNative, and started with CRNA+Expo. Unfortunately, we need to use some native modules and have to detach. But we loved the way Expo provides development process and still want to use it. We are thinking about the followed scheme:

  1. App Component: develop most of app cases in Expo environment, skip some native-required parts or replace them by Expo alternatives. For example, we cant use WebView module (because of silly UIWebView) in final app, but it is ok for testing base functionality.
    In a result it will be npm-packaged <AppComponent/>.

  2. App Container: bundle all native modules and provide them to <AppComponent/>.
    Something like this: <AppComponent providedModules={{webView: WKWebView, payment: nativePayments}}>

So, we can focus on base App development with fast live reload on the real devices.

Is that architecture reasonable? We are totally newbies in RN, and maybe just don’t know any other solutions for our case. Thank you!

(Oh, and sorry for my English)

Yup, that should work!

You can also just wrap the module in a file like this:

/* MyOptionalApi.js */
import { NativeModules } from 'react-native';

let apiToExport;
if (NativeModules.yourSpecialNativeModule) {
  // this will only exist if your custom native code is included
  apiToExport = NativeModules.yourSpecialNativeModule;
} else {
  // if it's not there, fall back to some other api
  apiToExport = SomeOtherMock;
}
export default apiToExport;

Then you could import MyOptionalApi from 'MyOptionalApi' and use it wherever, as long as the interface it exposes remains the same.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.