At React.js Conf 2015 Facebook announced React Native — a way to write native iOS and Android applications with JavaScript using the familiar React.js.
What is React Native
React Native is a way to build native apps in JavaScript using React.js for user interface.
It doesn’t use DOM for rendering, instead, it renders with native UI views. You write normal React components, but instead of using low-level DOM elements, you use native components provided by operating system, abstracted by React. For example, instead of <div>
you use <View>
, instead of <img>
, you use <Image>
, etc.
The virtual dom is an implementation detail of React.js. React Native demonstrates that many rendering contexts are possible.
— Bill Fisher (@fisherwebdev) January 28, 2015
How React Native does layout. #reactjsconf pic.twitter.com/4zDWTXkXIt
— React (@reactjs) January 29, 2015
How React Native works
React Native runs JavaScript engine in a separate background thread, which communicates with the native main thread using a batched async messaging protocol. There’s a plugin for React that uses this protocol for communication.
To write apps, you use the familiar React.js API, everything down to event bubbling. This is where the nice slogan “Learn once, write everywhere” comes from.
For UI layout and styling there is a cross-platform Flexbox-like layout system and a subset of CSS.
I say with confidence as a former UIKit author: React's model for the UI layer is vastly better than UIKit's. React Native is a *huge* deal.
— Andy Matuschak (@andy_matuschak) January 28, 2015
While developing, you can reload the app instantly in the simulator, like you do it in a browser.
The best thing about React Native is non obvious. Four words: No compilation, instant refresh.
What to do with all that free time?— Shane O'Sullivan (@chofter) January 28, 2015
The goal of React Native: "Less than one second between code change and updated app" #reactjsconf pic.twitter.com/cE0QYzre7X
— React (@reactjs) January 29, 2015
To write ReactNative apps you can use JSX or plain JavaScript, just like when writing React.js-based web apps. You can also use any other compile-to-JS languages, such as CoffeeScript or TypeScript.
Use in production
It turns out React Native is already used in production, even though it was just announced, in Facebook’s Groups application. Currently only the iOS app is build on it, not Android.
Available platforms
At this time React Native works on iOS and Android.
We're excited to have been able to talk about React Native at #reactjsconf. And yes, we will be open sourcing this very soon! 🙂
— Meta Open Source (@MetaOpenSource) January 28, 2015
Videos
Watch these videos from React.js Conf to learn more:
Introducing React Native
Tom Occhino’s keynote from the first day of conference talks about the past and future of React.js, introducing React Native and discussing why developers at Facebook decided to create it:
A Deep Dive into React Native
Christopher Chedeau demonstrates the React Native developer experience and discusses its architecture:
Update: React Native is now open source and available from https://facebook.github.io/react-native/.