Last active
August 1, 2017 04:39
-
-
Save cooperka/6442c3c7efc1d6b18cd72071e0f72b4e to your computer and use it in GitHub Desktop.
Migrating from ImmutableListView to ImmutableVirtualizedList in React Native (similar to FlatList).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Text, View } from 'react-native'; | |
-import { ImmutableListView } from 'react-native-immutable-list-view'; | |
+import { ImmutableVirtualizedList } from 'react-native-immutable-list-view'; | |
import style from './styles'; | |
import listData from './listData'; | |
class App extends Component { | |
- renderRow(rowData) { | |
- return <Text style={style.row}>{rowData}</Text>; | |
+ renderItem({ item, index }) { | |
+ return <Text style={style.row}>{item}</Text>; | |
} | |
render() { | |
return ( | |
<View style={style.container}> | |
<Text style={style.welcome}> | |
Welcome to React Native! | |
</Text> | |
- <ImmutableListView | |
+ <ImmutableVirtualizedList | |
immutableData={listData} | |
- renderRow={this.renderRow} | |
+ renderItem={this.renderItem} | |
/> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment