4
10 Comments

Do I need to know native development for react native?

Hi guys,

I know that RN is based on react, but I heard that there are "bridges" and I need to know native development. Is this true or not? And why do they say that I have to develop for Android and iOS. Isn't one codebase there for both?

on February 19, 2021
  1. 2

    React Native uses React to control and style the native components of each platform. They do have a <View> element which is practically a <div> equivalent.

    So if all you need are a bunch of <View>s and you do custom CSS for all of your components, it might be you don't need any platform-specific code at all.

    However some pre-built components act/look different on different platforms. In these cases you might need to do some if/else to get the app to work consistently on both platforms. If you want your iOS app to have "iOS look" and Android app to have "Android look", then you end up sharing mainly the business logic and codebase between the two apps.

    If you need some custom functionality (like integrating a third-party native library to your app), you need to jump out of Javascript and into Swift+Kotlin or Java+Obj-C to make "bridges" to your Javascript code. Most common native features like payments do have pre-existing plugins, but some plugins need to be installed to XCode/Android Studio to get them to work (in addition to making npm install packagename).

    You do have the option to use Expo so you never need to touch any native code at all, but in my opinion Expo is a pile of steaming 💩 that I wouldn't touch with a long stick.

    1. 1

      Curious why you don’t like expo. I just finished writing an enterprise level app with Expo and found it quite enjoyable. Sure, I had to get creative when there was some native functionality that wasn’t exposed through Expo, but that was worth it to me for the speed and comfort Expo provided.

      1. 1

        Bad things about Expo from a couple of bigger projects I've done with RN:

        • They bundle every single suported library to your app, so your app bundle size is pretty big
        • Ejecting Expo is a painful process if you've started with it and decide not to need it at some point
        • You get plugin updates only after Facebook adds them to Expo, so some plugins might be pretty old and there's nothing you can do about it
        • Installing your own plugins may result in clashes if Expo has some other version of your plugin. Or any shared dependency between any supported Expo plugin and the plugin you're trying to install.
        • At some point Play Store just decided to decline our app because Expo bundled the Facebook SDK (which we didn't use) and the Facebook SDK did some advertising/tracking stuff behind the scenes

        Of course Expo has its uses in small/simple projects and the time to hello world is superb compared to setting up all that stuff yourself.

        Edit: Note that experiences I have are from couple years back, so I hope things have improved since 😄

  2. 1

    Rather than ask a question like that, why not just check the docs?

    You'll get MUCH better answers reading it through than you will here.

    https://reactnative.dev/

    1. 1

      If you don't have anything beneficial to add, just scroll on and forget about this post. I did it already read the docs. But thanks again for your high-quality comment.

      1. 1

        This is beneficial.
        You didn't mention that you read the docs.
        None of the other comments mentioning the docs.
        Next time, please provide a higher quality question if you want higher quality answers.

        Edit:
        For example, the answer to your question is here:
        "Scenarios may arise where it makes sense for the code to be different, for example you may want to implement separate visual components for Android and iOS."
        https://reactnative.dev/docs/platform-specific-code

        Sorry, but I don't trust people when they said they read the docs but I found the answer in the docs in 30 seconds.

  3. 1

    I develop Android, iOS and React-Native code based applications and I'll say this.
    No, you don't need to know the native development of both platforms but there are times that it is going to be a big plus to help you solve problems and overcome some areas when you hit a wall.

    It also helps from a store perspective if you suddenly find something not making it past a review.

  4. 1

    It depends what you want to do, you can do a lot with Expo without touching any native code.

    If you want to do IAP, or other 'non-CRUD' stuff, you may need to use a RN hybird codebase.

  5. 1

    It really depends on the complexity of the app you're trying to build, and your willingness to adapt (or limit) to what's possible to do in React Native or not.

    For example, I had to create a share extension, and that quickly went over what's possible with React Native (at least back in the days).

    Another thing to keep in mind is you can find a lot of open source modules, they are great because they take care of the Native "bridge" for you, but when you find the perfect one in terms of UX and features, but it is not maintained anymore, you might need to do some Native fix to be able to use them.

  6. 1

    You don't need to. I've built some pretty advanced apps without knowing objective-c (iOS) or Java (android). You can go deeper and create custom modules for each platform, but only for super advanced features. I never had to do that.