Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5d4bfa

Browse files
committed
[README] New README co-authored with @brentvatne
This new README talks more about the react-native project, repository, and contribution process (the old one was more focused on technical details). @brentvatne and I want people to get help and file issues & PRs more effectively. Here's a first draft that we believe helps with that.
1 parent b81aa51 commit e5d4bfa

File tree

1 file changed

+50
-206
lines changed

1 file changed

+50
-206
lines changed

README.md

Lines changed: 50 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -1,219 +1,63 @@
11
# React Native [![Build Status](https://travis-ci.org/facebook/react-native.svg?branch=master)](https://travis-ci.org/facebook/react-native) [![npm version](https://badge.fury.io/js/react-native.svg)](http://badge.fury.io/js/react-native)
22

3-
React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and
4-
[React](http://facebook.github.io/react). The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.
5-
6-
## Native iOS Components
7-
8-
With React Native, you can use the standard platform components such as `UITabBar` and `UINavigationController` on iOS. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as _TabBarIOS_ and _NavigatorIOS_.
9-
10-
```javascript
11-
var React = require('react-native');
12-
var { TabBarIOS, NavigatorIOS } = React;
13-
14-
var App = React.createClass({
15-
render: function() {
16-
return (
17-
<TabBarIOS>
18-
<TabBarIOS.Item title="React Native" selected={true}>
19-
<NavigatorIOS initialRoute={{ title: 'React Native' }} />
20-
</TabBarIOS.Item>
21-
</TabBarIOS>
22-
);
23-
},
24-
});
25-
```
26-
27-
## Asynchronous Execution
28-
29-
All operations between the JavaScript application code and the native platform are performed asynchronously, and the native modules can also make use of additional threads as well. This means we can decode images off of the main thread, save to disk in the background, measure text and compute layouts without blocking the UI, and more. As a result, React Native apps are naturally fluid and responsive. The communication is also fully serializable, which allows us to leverage Chrome Developer Tools to debug the JavaScript while running the complete app, either in the simulator or on a physical device.
30-
31-
![](http://facebook.github.io/react-native/img/chrome_breakpoint.png)
32-
33-
34-
## Touch Handling
35-
36-
iOS has a very powerful system called the Responder Chain to negotiate touches in complex view hierarchies which does not have a universal analog on the web. React Native implements a similar responder system and provides high level components such as TouchableHighlight that integrate properly with scroll views and other elements without any additional configuration.
37-
38-
```javascript
39-
var React = require('react-native');
40-
var { ScrollView, TouchableHighlight, Text } = React;
41-
42-
var TouchDemo = React.createClass({
43-
render: function() {
44-
return (
45-
<ScrollView>
46-
<TouchableHighlight onPress={() => console.log('pressed')}>
47-
<Text>Proper Touch Handling</Text>
48-
</TouchableHighlight>
49-
</ScrollView>
50-
);
51-
},
52-
});
53-
```
54-
55-
56-
## Flexbox and Styling
57-
Laying out views should be easy, which is why we brought the flexbox layout model from the web to React Native. Flexbox makes it simple to build the most common UI layouts, such as stacked and nested boxes with margin and padding. React Native also supports common web styles, such as `fontWeight`, and the `StyleSheet` abstraction provides an optimized mechanism to declare all your styles and layout right along with the components that use them and apply them inline.
58-
59-
```javascript
60-
var React = require('react-native');
61-
var { Image, StyleSheet, Text, View } = React;
62-
63-
var ReactNative = React.createClass({
64-
render: function() {
65-
return (
66-
<View style={styles.row}>
67-
<Image
68-
source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}}
69-
style={styles.image}
70-
/>
71-
<View style={styles.text}>
72-
<Text style={styles.title}>
73-
React Native
74-
</Text>
75-
<Text style={styles.subtitle}>
76-
Build high quality mobile apps using React
77-
</Text>
78-
</View>
79-
</View>
80-
);
81-
},
82-
});
83-
var styles = StyleSheet.create({
84-
row: { flexDirection: 'row', margin: 40 },
85-
image: { width: 40, height: 40, marginRight: 10 },
86-
text: { flex: 1, justifyContent: 'center'},
87-
title: { fontSize: 11, fontWeight: 'bold' },
88-
subtitle: { fontSize: 10 },
89-
});
90-
```
91-
92-
## Polyfills
93-
94-
React Native is focused on changing the way view code is written. For the rest, we look to the web for universal standards and polyfill those APIs where appropriate. You can use npm to install JavaScript libraries that work on top of the functionality baked into React Native, such as `XMLHttpRequest`, `window.requestAnimationFrame`, and `navigator.geolocation`. We are working on expanding the available APIs, and are excited for the Open Source community to contribute as well.
95-
96-
```javascript
97-
var React = require('react-native');
98-
var { Text } = React;
99-
100-
var GeoInfo = React.createClass({
101-
getInitialState: function() {
102-
return { position: 'unknown' };
103-
},
104-
componentDidMount: function() {
105-
navigator.geolocation.getCurrentPosition(
106-
(position) => this.setState({position}),
107-
(error) => console.error(error)
108-
);
109-
},
110-
render: function() {
111-
return (
112-
<Text>
113-
Position: {JSON.stringify(this.state.position)}
114-
</Text>
115-
);
116-
},
117-
});
118-
```
119-
120-
## Extensibility
121-
122-
It is certainly possible to create a great app using React Native without writing a single line of native code, but React Native is also designed to be easily extended with custom native views and modules - that means you can reuse anything you've already built, and can import and use your favorite native libraries. To create a simple module in iOS, create a new class that implements the `RCTBridgeModule` protocol, and wrap the function that you want to make available to JavaScript in `RCT_EXPORT_METHOD`. Additionally, the class itself must be explicitly exported with `RCT_EXPORT_MODULE();`.
123-
124-
```objc
125-
// Objective-C
126-
127-
#import "RCTBridgeModule.h"
128-
129-
@interface MyCustomModule : NSObject <RCTBridgeModule>
130-
@end
131-
132-
@implementation MyCustomModule
133-
134-
RCT_EXPORT_MODULE();
135-
136-
// Available as NativeModules.MyCustomModule.processString
137-
RCT_EXPORT_METHOD(processString:(NSString *)input callback:(RCTResponseSenderBlock)callback)
138-
{
139-
callback(@[[input stringByReplacingOccurrencesOfString:@"Goodbye" withString:@"Hello"]]);
140-
}
141-
142-
@end
143-
```
144-
145-
```javascript
146-
// JavaScript
147-
148-
var React = require('react-native');
149-
var { NativeModules, Text } = React;
150-
151-
var Message = React.createClass({
152-
getInitialState() {
153-
return { text: 'Goodbye World.' };
154-
},
155-
componentDidMount() {
156-
NativeModules.MyCustomModule.processString(this.state.text, (text) => {
157-
this.setState({text});
158-
});
159-
},
160-
render: function() {
161-
return (
162-
<Text>{this.state.text}</Text>
163-
);
164-
},
165-
});
166-
```
167-
168-
Custom iOS views can be exposed by subclassing `RCTViewManager`, implementing a `-view` method, and exporting properties with the `RCT_EXPORT_VIEW_PROPERTY` macro. Then use `requireNativeComponent` in JavaScript to use the component in your app.
169-
170-
```objc
171-
// Objective-C
172-
173-
#import "RCTViewManager.h"
174-
175-
@interface MyCustomViewManager : RCTViewManager
176-
@end
177-
178-
@implementation MyCustomViewManager
179-
180-
RCT_EXPORT_MODULE()
181-
182-
- (UIView *)view
183-
{
184-
return [[MyCustomView alloc] init];
185-
}
3+
React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and [React](http://facebook.github.io/react). The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.
1864

187-
RCT_EXPORT_VIEW_PROPERTY(myCustomProperty, NSString);
5+
## Getting Started
1886

189-
@end
190-
```
7+
- Follow the [Getting Started guide](http://facebook.github.io/react-native/docs/getting-started.html) to install React Native and its dependencies.
8+
- Check out this [tutorial](https://facebook.github.io/react-native/docs/tutorial.html) to walk through your first project that fetches real data and displays it in a list.
9+
- [Open the UIExplorer example project](#examples) to see a list of components that ship with React Native.
10+
- Install the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi) for Chrome or Firefox for better debugging [(read more)](http://facebook.github.io/react-native/docs/debugging.html).
11+
- Try out apps from the [Showcase](https://facebook.github.io/react-native/showcase.html) to see what React Native is capable of!
19112

192-
```javascript
193-
// JavaScript
13+
## Getting Help
19414

195-
var React = require('react-native');
196-
var { requireNativeComponent } = React;
197-
198-
class MyCustomView extends React.Component {
199-
render() {
200-
return <NativeMyCustomView {...this.props} />;
201-
}
202-
}
203-
MyCustomView.propTypes = {
204-
myCustomProperty: React.PropTypes.oneOf(['a', 'b']),
205-
};
15+
- Ask a question on [StackOverflow](http://stackoverflow.com/) and tag it with `react-native`
16+
- Start a thread on the [React Discussion Board](https://discuss.reactjs.org/)
17+
- Join #reactnative on IRC: chat.freenode.net
18+
- Slack: Sign up for [Reactiflux](http://reactiflux.com/) and join #react-native
19+
- If it turns out that you may have found a bug, please [open an issue](#opening-issues)
20620

207-
var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView);
208-
module.exports = MyCustomView;
209-
```
21+
## Documentation
21022

211-
## Running the Examples
23+
- [The website’s documentation](https://facebook.github.io/react-native/docs/) divided into multiple sections.
24+
There are **Guides** that discuss topics like [debugging](https://facebook.github.io/react-native/docs/debugging.html), [integrating with existing apps](https://facebook.github.io/react-native/docs/embedded-app-ios.html), and [the gesture responder system](https://facebook.github.io/react-native/docs/gesture-responder-system.html).
25+
- The **Components** section covers React components such as [`View`](https://facebook.github.io/react-native/docs/view.html) and [`Navigator`](https://facebook.github.io/react-native/docs/navigator.html).
26+
- The **APIs** section covers other libraries like [Animated](https://facebook.github.io/react-native/docs/animated.html) and [StyleSheet](https://facebook.github.io/react-native/docs/stylesheet.html) that aren’t React components themselves.
27+
- Finally, React Native provides a small number of **Polyfills** that offer web-like APIs.
28+
29+
Another great way to learn more about the components and APIs included with React Native is to read their source. Look under the `Libraries` directory for components like `ScrollView` and `Navigator`, for example. The UIExplorer example is also here to demonstrate some of the ways to use these components. By looking at the source you can get an accurate understanding of each component’s behavior and API.
30+
31+
The React Native documentation only discusses the components, APIs and topics specific to React Native (React on iOS and Android). For further documentation on the React API that is shared between React Native and React DOM, refer to the [React documentation](http://facebook.github.io/react/).
32+
33+
## Examples
21234

21335
- `git clone https://github.com/facebook/react-native.git`
21436
- `cd react-native && npm install`
215-
- `cd Examples`
21637

217-
Now open any example and hit run in Xcode.
38+
Now open any example (the `.xcodeproj` file in each of the `Examples` subdirectories) and hit Run in Xcode.
39+
40+
## Extending React Native
41+
42+
- Looking for a component? [react.parts](http://react.parts/)
43+
- Fellow developers write and publish React Native modules to npm and open source them on GitHub.
44+
- Making modules helps grow the React Native ecosystem and community. We recommend writing modules for your use cases and sharing them on npm.
45+
- Read the [Native Modules iOS](http://facebook.github.io/react-native/docs/native-modules-ios.html#content) and [Native UI Components iOS](http://facebook.github.io/react-native/docs/native-components-ios.html#content) guides in the documentation if you are interested in extending native functionality.
46+
47+
## Opening Issues
48+
49+
If you encounter a bug with React Native we would like to hear about it. Search the [existing issues](https://github.com/facebook/react-native/issues) and try to make sure your problem doesn’t already exist before opening a new issue. It’s helpful if you include the version of React Native and iOS you’re using. Please include a stack trace and reduced repro case when appropriate, too.
50+
51+
The GitHub issues are intended for bug reports and feature requests. For help and questions with using React Native please make use of the resources listed in the [Getting Help](#getting-help) section. There are limited resources available for handling issues and by keeping the list of open issues lean we can respond in a timely manner.
52+
53+
## Contributing
54+
55+
For more information about contributing, see our [Contribution Guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md).
56+
57+
## License
58+
59+
React is [BSD licensed](./LICENSE). We also provide an additional [patent grant](./PATENTS).
60+
61+
React documentation is [Creative Commons licensed](./LICENSE-docs).
21862

219-
Further documentation, tutorials, and more on the [React Native website](http://facebook.github.io/react-native/docs/getting-started.html).
63+
Examples provided in this repository and in the documentation are [separately licensed](./LICENSE-examples), as are some of the [custom components](./LICENSE-CustomComponents).

0 commit comments

Comments
 (0)