Skip to content

Commit 6525f94

Browse files
committed
Merge pull request #132 from charpeni/readme-rn-0.25
Update README to React Native 0.25
2 parents 2110839 + a90e1b4 commit 6525f94

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import Router from 'react-native-simple-router';
2222

2323
The basics:
2424
```javascript
25-
26-
import React, { StyleSheet } from 'react-native';
25+
import React from 'react';
26+
import { StyleSheet } from 'react-native';
2727

2828
// The initial page
2929
class HelloPage extends React.Component {
@@ -69,14 +69,14 @@ Boom. That's it.
6969
From the "Hello world!"-page you can then navigate further to a new component by calling ```this.props.toRoute()```. Let's build upon the HelloPage component in our first example:
7070

7171
```javascript
72-
import React, { StyleSheet, PropTypes } from 'react-native';
72+
import React, { PropTypes } from 'react';
73+
import { StyleSheet } from 'react-native';
7374

7475
const propTypes = {
7576
toRoute: PropTypes.func.isRequired,
7677
};
7778

7879
class HelloPage extends React.Component {
79-
8080
constructor(props) {
8181
super(props);
8282

@@ -102,6 +102,8 @@ class HelloPage extends React.Component {
102102
}
103103

104104
HelloPage.propTypes = propTypes;
105+
106+
export default HelloPage;
105107
```
106108

107109
Now, when you click on "Next page please!", it will go to the next page (which in this case is still HelloPage but with a new title). Keep in mind that ```this.props.toRoute()``` needs to be called from one of the top-level routes, therefore, if your link is deeply nested within multiple components, you need to make sure that the action "bubbles up" until it reaches the parent route, which in turn calls ```this.props.toRoute()```.
@@ -232,7 +234,7 @@ To see more of the router in action, you can check out the Twitter example app t
232234
Test the app by requiring the TwitterApp component:
233235

234236
```javascript
235-
import React, { AppRegistry } from 'react-native';
237+
import { AppRegistry } from 'react-native';
236238
import TwitterApp from './node_modules/react-native-simple-router/examples/twitter-example';
237239

238240
AppRegistry.registerComponent('routerTest', () => TwitterApp);

0 commit comments

Comments
 (0)