React Native Questions

React Native Questions
0

This week I published an app built with React.js that was wrapped with Cordova for Android and iOS. Initially this was a pretty fun way to build an app, but towards the end when trying to fine tune the UI and other things on each platform it started to get pretty painful because of needing to wait for React to build followed by a Cordova platform build, and then waiting for the emulator(s) to load.

I’d like to try building my next app using React-Native because of the live loading, but I have a few concerns. My main concern is that right now I’m not wanting to learn or write any native code in Java, Obj-C, or Swift. One thing I’ve liked about Cordova is the community has made lots of plugins for things like in-app-purchases, advertisement frameworks, sqlite, etc., so that I can just install them and then write my code in JS.

How frequently, if at all, would I need to write native code if using React-Native?

My second question is are there any major limitations that React-Native can’t do that React does? I realize this is a broad question, but I’m thinking more big picture larger issues rather than the nuances.

Any suggestions for a noob going from React to React-Native would be appreciated before I dive in. I’m starting to feel comfortable using React.js, and figure it’s time to dive in to React-Native now.

Thanks for any advice you can offer.

Hello!

I’m not a react nor react native developer, but I do have experience with Android development (Java/Kotlin) and Cordova. Plus, I have some experience with NativeScript, which is an alternative to React Native (it allows you to use React, Vue or Angular to build native apps).

Whenever a feature you need requires a plugin that doesn’t exists for. This means, if you require some special access to the hardware, but there is no plugin to give it to you, then you’ll have to write that plugin. I can’t tell you when or how often this will happen, since it will depend on each case.

I don’t think that’s a fair comparison :stuck_out_tongue:. React is meant to work on the web, whereas react native is meant to create native apps using a syntax you already know. It’s not the idea to share functionalities among both libraries (there are, of course), but to use something you already know to create something you don’t know. It’s a modified tool to do what wasn’t meant to do initially.

Well, since I’m not an expert, feel free to ignore me and wait for a more experienced user response.

I hope it helps you a little :slight_smile:,

Happy coding!

1 Like

Almost never, though YMMV if you want to do something very specific.

Well, it’s not v1 yet. And it’s a cross-platform framework, so it makes tradeoffs to make things work across different platforms.

It has a fairly huge community. Most of the knowledge transfers from React, a lot of the code is portable. You have access to a helluva lot of JS stuff whilst using it, covers many eventualities.

The recommended way to use it is through Expo, which makes development pretty pleasant and means you don’t need XCode or Android Studio much of the time. But Expo doesn’t allow arbitrary extensions/libraries that use native code, so you have to stick with what they provide, which can be a pain. Using RN out of the box avoids this issue, but then you tend to get into build issues (which can be very painful). If you’re building iOS and Android in that case you really need something powerful with a lot of memory and storage. The de facto standard navigation library (react navigation) is powerful but slightly bizarre to use, though that’s gotten a helluva lot better with the new v5 release. Errors can be almost completely useless fairly often, particularly when you are using react-navigation. Animations are very powerful, but the documentation is generally crap for implementing them. It uses a port of part of CSS to C++ (the Yoga library) for layout and styling, and it is constrained (everything is based on flex) – I don’t think this is too much of a downside though, having those constraints is fine. Main issue I find is that it isn’t browser CSS, you need to define styling for every single element individually – again, not a huge issue, because what you tend to do is write styled wrappers around each of the built in elements you want to use, and then use those wrappers. Project structure can get quite messy.

1 Like

As a RN developer, I’ve never had to write native code. I work on a pretty advanced app and the only time I’ve seen anyone have to do something like that is having to adjust a few lines if we were doing something very low level. But for most apps, that shouldn’t be an an issue. I wouldn’t worry about that.

What can React do that RN can’t? I can’t think of anything that isn’t obviously related to web vs. mobile. Remember that React Native is React. You are writing in React.

When people ask me the differences, I mostly tell them that React Native is React but because it is mobile, your JSX is going to look different because there are no divs and spans and h1s, but there are Views and Texts and other RN components that fill the function of the HTML elements you know. Also, you don’t have a full implementation of CSS, but you have a handy subset of that that will be instantly understandable. Seriously, that’s most of it right there. The hardest part for me was getting the environment set up. Really, that took forever. After that, anyone that can use React will quickly and easily start writing in React Native. There are few little speed bumps, but not nearly as many as you fear.

2 Likes

Thanks a ton for your response and insight!

Awesome, thank you. I’ll have to find a guide for the CSS differences or figure it out trial and error. Appreciate your response.

Seriously, the CSS differences are minor. It’s just a subset (but the most important parts), the property names are camel case, and you rely a little more on flex box. Seriously, you won’t need to study it. Just go for it and consult the docs when things aren’t working.

1 Like

Adjusting code for different devices is a pain for just Apple products. My codebase supports grids up to 25 x 25 in straight or transformed 45 degrees. Transforms look easy, until you try to reference a views center, size, etc., lol.

Native Swift now runs on Mac too, or soon with minor modifications. Anyone here proficient in Swift, and even interested in any other language? Swift 5 is finally stable with a sizable help base! Anyone have any basis to compare native Swift 5 with React, etc. ?