var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
React.render(<HelloMessage name="John" />, mountNode);
render() {
return (
<View style={{marginTop: 20}}>
<Text>Checklist</Text>
<TextInput
style={styles.input}
autoFocus={true}
onSubmitEditing={this.handleSubmit}
/>
<View style={styles.list}>
{this.renderItems()}
</View>
</View>
);
}
Following on from the announcement on Wednesday (28th January), Christopher Chedeau (Software Developer, Facebook) delivered a talk titled “A Deep Dive into React Native”. In his talk Christopher identified three areas where React Native can improve the app development experience versus using standard web or native approaches:
- Touch Handling - mobile apps built upon web technologies (HTML5/JavaScript) are often critiqued for feeling unresponsive - by avoiding these technologies in favour of native rendering React Native apps can appear more responsive.
- Native Components - often components written in HTML5/JavaScript fall short of their native counterparts and ’never feel as good as native', React Native avoids this by providing access to the native UI components.
- Style and Layout - iOS, Android and web based apps all have different mechanisms for laying out and styling applications. React Native provides a single consistent mechanism for styling and laying out apps on all mobile platforms (with a layout engine based on FlexBox).
Commenting in a discussion on the announcement on Hacker News, Peter Hunt (React contributor) provided an insight into the internal workings of React Native:
- JS engine on a background thread
- Communicates via batched, async messaging protocol to a native (objc or android) server running on the main thread (basically create_view(), update_view(), destroy_view(), on_event() etc)
- Plug-in for React that speaks that protocol
- Tools to make cross-platform dev a bit easier (standard text component, cross-platform flexbox layout system)
- Designed to take advantage of native platform views, NOT be the next Java Swing
Facebook have yet to announce when Reactive Native will be publicly available - and the library is still subject to ongoing development within the company. It is however at a functional stage of development and has been utilised in a number of publicly available applications, including the Facebook Groups iOS App.