A Deep Dive on React Native [video]
youtube.com
youtube.com
I normally listen for a few minutes at double speed, then drop down to 1.5 if necessary.
Sometimes speeding up just isn't a viable option. I'm glad I had the time to watch the whole video last night, but I too am looking forward to blog posts, documentation, and code releases. Way easier for me to digest quickly, and at my own pace.
It's interesting that they are making a private repo available to attendees. I suppose they want to get some feedback and start some hype but also want to ensure a smooth initial public release.
Perhaps some community members with access to the private repo will blog their own impressions, if that's not discouraged?
Ideally a cross pollination of ideas about animations would make both ecosystems better.
Um, we totally use jquery-ui's drag and drop in a React component in production and nothing bad happens.
One is implemented fully in JS and is used when we need to implement gestures and respond to ongoing touch interactions. This is tricky because we need to be very careful to keep our JS frames very short and fast during the gesture, avoiding expensive allocations and making sure we don't try to process too much data in Relay.
The other API is much more magical. You configure the animation for your component immediately before a setState. The new layout is computed normally, but instead of directly updating the native views, we use POP[1] to animate to them on the main thread. This is a really easy-to-use API, but there are a few caveats.
We're still developing, stabilizing, and cleaning up these tools. It's great to hear your interested in this, we'll try to open something up before too long!
Creating and calling native UI components from JavaScript is nothing special in itself. It's obviously possible to do it from JS just as well as from any other language -- you just need to provide the API. There you have two choices: either a bridge that translates the native API directly, or a wrapper class hierarchy.
Examples of bridges include Xamarin's Mono that lets you build iOS user interfaces in C# code, and RubyMotion that lets you build Mac UIs in Ruby. Because these are bridges, the entire Cocoa API is exposed. The downside is that the bridge does nothing to smooth over platform differences: you can write in C# on all platforms, but you still have to learn Cocoa.
A prominent example of a wrapper API is Titanium Appcelerator that lets you build cross-platform mobile apps. Another good example is GTK+ for desktop apps: it's smart enough to leverage native Windows components where possible, but the GTK+ API is higher level than that of native Win32.
React Native is primarily in the latter category. Based on jordwalke's comment in another HN thread, they currently have cross-platform wrappers for View and Image:
https://news.ycombinator.com/item?id=8965044
But it appears you can also create platform-specific views, and for that they presumably have some kind of bridge. (It could also be that they provide manually written wrappers for platform-specific views, e.g. UIMapView becomes a <Map> and so on.)
In sum: React Native doesn't magically translate your JS+HTML app into a cross-platform native app. They're a long way off from having a full cross-platform API (unless your app is so simple that it can be described in terms of <View> and <Image>). And, like all wrapper APIs, there is a degree of impedance mismatch between the underlying platform implementation and the cross-platform interface on top.
There's a lot to like about React Native, though. The layout model and binding logic seems cool. The React team's accomplishments in the browser environment are impressive. With time, React Native could become for mobile what Qt is on the desktop -- and that's high praise in my books.
> With time, React Native could become for mobile what Qt is on the desktop -- and that's high praise in my books.
Sounds like maybe you're not so puzzled after all?
I'm not sure what you're hearing is hype. I think it's just excitement. Nobody is declaring this as The One True Way just yet, but a lot of people (you and I included, it seems) are cautiously optimistic that it could make mobile development a lot better.
People are talking about how they'll use React Native for new apps without any regard for whether it makes sense in the particular case or not. So I tried to calm down those expectations a bit.
This could be the answer to that, and I wouldn't need to hack my own idioms together.
That results in two different classes of Native components:
- Cross-platform components that are nearly identical on each platform- Eg. <View>, <Text>, <Image>, <TextInput>, <ListView>. There will not be many more of these
- Platform-specific components- When there is not an identical API and feature-set, we provide bridged components which can take full advantage of the platform. There will be a lot of these, but we currently only have a handful.
The real power comes from React's component-driven declarative programming style. The asynchronous batched bridge is well designed, but it's nothing special.
It's about building native applications in the React style (declarative, componentised), with very rapid turnaround because much of your logic and layout is defined in JavaScript. Instead of recompiling your app's native code all the time, you're just reloading JavaScript within it.
It's possible that some components could be shared between platforms, but ultimately I think most of them will be different, reflecting the UI structure of the target environment. There's probably more scope for sharing higher level non-UI-element components.
1) Is this cross platform or are you still going to have separate code bases for the UIs of iOS and Android? Looking at the code in the demo there are components like View, Text and Image. As basic as they are, are they the same on iOS and Android (same behaviour, same arguments)? It was pretty clear from the first minutes of the video that View is build on top of the native view of iOS (he showed the objC code). Is that React code building for Android?
2) I guess that one must still be proficient in iOS and Android, unless they make the monumental job of rewriting all the iOS and Android documentation for the React components they implemented. I expect to have to reference the native docs to understand the meaning of the arguments and do the job of mapping React to native. That has always been a pain point in many UI abstraction layers.
It was stated it used 4th tier LLVM JIT (FTL) [0]. Do you have evidence to the contrary? What did you do to test? If you can outline what you did I will be happy to help out and investigate.
[0]: https://www.webkit.org/blog/3362/introducing-the-webkit-ftl-...
That just seems SO much easier, quicker, and more efficient than storyboarding and coding UIViews. I am very much looking forward to being able to play around with this and discover downsides, because there have to be some...right?
http://jsfiddle.net/u8wd8kdL/5/
If I am wrong, please provide me an example of how to layout that text with display:flex.
"This is a native component". "WOOOOOOOOH!!!" "YEAH!!" <high fives>
Hmmmm.
An interesting idea, however Apple might have something to say about that (App Store Review Guidelines):
2.7 Apps that download code in any way or form will be rejected
2.8 Apps that install or launch other executable code will be rejected
Still...I like the idea of pushing the boundaries of native iOS development.
From what I understood on the video, this is going to be distributed via a repo that is essentially already an iOS or Android template?
There wasn't much talk about the compilation process. Maybe the details (for the open source version) haven't been ironed out?
Because flex-box has been re-implemented in JS, does this mean that the css-layout project [1] will provide flex-box support for older browsers?
I looked, but I couldn't find a "compatibility" section anywhere in the repo.
My current issue is how to measure text sizes: https://github.com/facebook/css-layout/blob/master/src/__tes...
This article have lot of details about how JS is getting executed on the Native platform. Lot of components are provided by Apple like JS VM
It's like how we never got a fix for making cross platform applications. And regardless how much people wants the new way of doing things to work, the results speak for themselves. Atom, the editor, can't even handle window re-sizing smoothly.
It's actual native components, with the intent that you "learn once, write everywhere" rather than try to jam iOS and Android into the same codebase.
It's all native and even with xplat Xamarin.Forms you can customize code for each platform.
Also, the constraint solver could be a good riddance but is there going to be any support for uikit dynamics ?