Live data from Hacker News

React Native for Android

code.facebook.com

191–200 of 248 posts

Re: React Native for Android

#191

Question for everybody doing some sort of cross platform mobile dev. How common is it to have NO experience with a platform's native libraries? In other words you didn't go from ObjC or Java to React Native/Cordova/Xamarin to try and re-use code but because you know JS or C# and weren't concerned about learning the native platform. For any that started out with no native platform knowledge did you start to dip into i…

If you stick with the tools which actually don't abstract the native platforms (e.g. RoboVM and Xamarin), I think you will learn native development quite easily. I've taken this approach, and I've had no trouble using documentation/StackOverflow to write equivalent code in Java/C#. Since pretty much all the APIs in these tools are 1-1 with the native APIs, I've also had no trouble going in the reverse direction and writing Swift/Objective-C/Java. You will still need to learn the languages, but you won't need to re-learn the APIs (which is the time consuming part).

Personally, I see little to no disadvantage with using these particular types of tools, especially if it means you can use languages like Scala, C#, and F# instead of Objective-C and Java.

Re: React Native for Android

#192

Earlier quoted context omitted.

Using Cordova, you will always be behind any and all Mobile Safari WebKit et al bugs. This not a big deal when pushing layout around a webpage, but it can be crippling for app development as the app grows in complexity and you crave native-quality interactions. Mobile Safari's Webkit implementation has a staggering list of severe bugs. Developing under it can become a nightmare of hacks and backpedaling. Been working…

> This not a big deal when pushing layout around a webpage, > but it can be crippling for app development as the app > grows in complexity and you crave native-quality > interactions Even on the fastest phones, web-based (including wrapped web components) simply don't offer the native experience. They come close, but there's always a slight but perceptible performance difference; and often a visual difference dependi…

I used to think same way, but 99% of your user won’t feel that way.

My hacker news app is a hybrid app. Available on iOS/Android/Windows/Mac and web, and I harldy see any one compalining about not being native.

There are some legit issues and peole think only way to fix is go native. Only reason I have not fixed those issues because I don’t have time, or I don’t use that functinality.

Re: React Native for Android

#193
post #148

Earlier quoted context omitted.

Can you explain the assertion that DOM rendering is O(1)?

Of course. For example, suppose that there is a button in your UI that changes color whenever you click on it. Changing the color of that button in response to a click can be done in a simple Javascript function that takes O(1) time. However, doing it the React way, all buttons on the screen have to be traversed, O(N), and diff/patched into a new DOM, which is heuristically O(1). However O(N+1) = O(N), so React takes…

It's because anyone who has done any complex web app development knows that you don't have one button changing color. You have 100+ UI components whose state may depend on one another, and as the DOM nodes composing those UI elements get state attached to them, it's EXTREMELY easy for them to both (1) get out of sync, and (2) thrash and re-render entire trees of the DOM unnecessarily. This is a real thing that happens frequently and is why people think JavaScript causes pages to be slow and janky.

React lets developers pretend they CAN just re-render entire DOM trees from scratch without those consequences, as if they were serving up a fresh server-side render of the page.

Also, suggesting that before React, web apps were updating all their DOM nodes in O(1) time is insane – even if it's not the absolute fastest, why does it compare so favorably in actual tests, then?

Re: React Native for Android

#194

Are there any high-profile apps using React Native other than those from FB? Native dev here, but considering an Android port, so wondering if maybe RN would be better.

Not too many, you can see a showcase here http://facebook.github.io/react-native/showcase.html

I believe larger companies are currently working towards React Native apps though.

Re: React Native for Android

#196
I don't see how you can make a single cross-platform experience from a single JS / JSX file. The sample has two different main.js files, one for each platform:

     // iOS 
     var React = require('react-native');
     var { TabBarIOS, NavigatorIOS } = React;

     // Android

     var React = require('react-native');
     var { DrawerLayoutAndroid, ProgressBarAndroid } = React;
How can you determine the platform at runtime and dynamically build the layout for each? I'm guessing, we'll have to expose a native function that returns the active platform, although it seems weird this doesn't already exist.

I wonder why the team decided not to abstract the functionality a bit, like Xamarin did with Forms, so something as common as tab view could be constructed in a cross-platform manner? I understand the urge to keep the platforms feeling native, but a little abstraction could go a long way.

Re: React Native for Android

#197

I don't see how you can make a single cross-platform experience from a single JS / JSX file. The sample has two different main.js files, one for each platform: // iOS var React = require('react-native'); var { TabBarIOS, NavigatorIOS } = React; // Android var React = require('react-native'); var { DrawerLayoutAndroid, ProgressBarAndroid } = React; How can you determine the platform at runtime and dynamically build th…

That is by design. React native isn't intended to be write-once, run-anywhere. iOS and Android UIs are just too different for that to work well.

Instead, React Natives gives you a place (javascript) where logic can be shared between iOS and Android, and a common approach to rendering that leads to lots of shared code.

Re: React Native for Android

#198

I don't see how you can make a single cross-platform experience from a single JS / JSX file. The sample has two different main.js files, one for each platform: // iOS var React = require('react-native'); var { TabBarIOS, NavigatorIOS } = React; // Android var React = require('react-native'); var { DrawerLayoutAndroid, ProgressBarAndroid } = React; How can you determine the platform at runtime and dynamically build th…

- You can determine the platform with React.Platform -- eg:

var React = require('react-native');

var { Platform } = React;

if (Platform.OS === 'ios') {

  // lol steve jobs
} else {

  // lol robutts
}

Android also has a `Version` property on `Platform`.

- Certain features are not idiomatic on both platforms: where you might use TabBar on iOS you are going to use a Drawer on Android. NavigatorIOS is a wrapper around UINavigationController that is not maintained as part of the core React Native project, but is a community effort -- nobody at Facebook uses it, and nobody who makes any serious apps with React Native use it either; instead, they use the cross-platform Navigator component, written entirely in JS. Similarly, if you really want to use a TabBar on Android, there exists at least one excellent JS implementations of this that you can use: https://github.com/exponentjs/react-native-tab-navigator

- This is still a very early release! In fact, it is the first day it is released. There are plans to bring the APIs together where it makes sense. For example, SwitchAndroid and SwitchIOS will be brought together under a Switch component that has the same API on both platforms but uses their underlying native implementations.

Re: React Native for Android

#199
post #90

Earlier quoted context omitted.

Google is working on it: https://github.com/domokit/sky_engine and https://github.com/dart-lang/fletch

This looks like more of a side project than something Google is going to put its weight behind. I am pretty excited for Fletch though - I hope it turns into something like React Native, which would be much improved using Dart and Dart tools instead of JavaScript IMO. Right now Fletch looks pretty awkward/painful to use though. Writing views completely natively (ObjC/Swift/Java) and then calling into a DartVM for busi…

I'd be really curious to hear what makes Dart tools awesome. I haven't played with Dart, but JS has some of the best tooling I've used. Have you tried webpack and hotloading? Have you tried npm (with webpack to generate client-side bundles) as your dependency manager?

Re: React Native for Android

#200

Earlier quoted context omitted.

> This not a big deal when pushing layout around a webpage, > but it can be crippling for app development as the app > grows in complexity and you crave native-quality > interactions Even on the fastest phones, web-based (including wrapped web components) simply don't offer the native experience. They come close, but there's always a slight but perceptible performance difference; and often a visual difference dependi…

I used to think same way, but 99% of your user won’t feel that way. My hacker news app is a hybrid app. Available on iOS/Android/Windows/Mac and web, and I harldy see any one compalining about not being native. There are some legit issues and peole think only way to fix is go native. Only reason I have not fixed those issues because I don’t have time, or I don’t use that functinality.

I use the app on Android and it's the best HN app on Android but at times it is obvious that it is not native and it has some issues as you said. What I have encountered are

1. I get an error message "Unable to load xxxx" at times (forgot the exact message) and the app closes.

2. If I switch between article/comments it always reloads

3. At times clicking on the comments icon doesn't work when you are in article mode.

4. I can't long press on links in comments to share it to browser/pocket etc

Compared to reddit apps like Relay, the HN app does feel much more basic.

Post reply on HN