Skip to content

Commit

Permalink
ES6-ify ListView Basics
Browse files Browse the repository at this point in the history
Summary:
Fixes facebook#8184
Closes facebook#8370

Differential Revision: D3477196

Pulled By: caabernathy

fbshipit-source-id: 929f84b3f8edaf03f918bb04fb9dbb48b4884b18
  • Loading branch information
JoelMarcey authored and Morgan Pretty committed Aug 24, 2016
1 parent ad51a8b commit 5381bc4
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions docs/Basics-Component-ListView.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ This example creates a simple `ListView` of hardcoded data. It first initializes
> A `rowHasChanged` function is required to use `ListView`. Here we just say a row has changed if the row we are on is not the same as the previous row.
```JavaScript
import React from 'react';
import React, { Component } from 'react';
import { AppRegistry, ListView, Text, View } from 'react-native';

var AwesomeList = React.createClass({
class ListViewBasics extends Component {
// Initialize the hardcoded data
getInitialState: function() {
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
return {
constructor(props) {
super(props);
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows([
'John', 'Joel', 'James', 'Jimmy', 'Jackson', 'Jillian', 'Julie'
])
'John', 'Joel', 'James', 'Jimmy', 'Jackson', 'Jillian', 'Julie', 'Devin'
])
};
},
render: function() {
}
render() {
return (
<View style={{paddingTop: 22}}>
<ListView
Expand All @@ -43,8 +44,8 @@ var AwesomeList = React.createClass({
</View>
);
}
});
}

// App registration and rendering
AppRegistry.registerComponent('AwesomeProject', () => AwesomeList);
AppRegistry.registerComponent('AwesomeProject', () => ListViewBasics);
```

0 comments on commit 5381bc4

Please sign in to comment.