Skip to content

Commit e714d62

Browse files
ymainiercharpeni
authored andcommitted
Fix a warning in the Networking Fetch Example (facebook#391)
* Fix a warning in the Networking Fetch Example While running the fetch example, I saw this warning : ```ExceptionsManager.js:71 Warning: Failed child context type: Invalid child context `virtualizedCell.cellKey` of type `number` supplied to `CellRenderer`, expected `string`.``` I verified in the [doc](https://facebook.github.io/react-native/docs/flatlist.html#keyextractor), `keyExtractor` should return a `string`. * Add an id in movies.json and use this id as key
1 parent af15e60 commit e714d62

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/network.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default class FetchExample extends React.Component {
118118
<FlatList
119119
data={this.state.dataSource}
120120
renderItem={({item}) => <Text>{item.title}, {item.releaseYear}</Text>}
121-
keyExtractor={(item, index) => index}
121+
keyExtractor={({id}, index) => id}
122122
/>
123123
</View>
124124
);

website/static/movies.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"title": "The Basics - Networking",
33
"description": "Your app fetched this from a remote endpoint!",
44
"movies": [
5-
{ "title": "Star Wars", "releaseYear": "1977"},
6-
{ "title": "Back to the Future", "releaseYear": "1985"},
7-
{ "title": "The Matrix", "releaseYear": "1999"},
8-
{ "title": "Inception", "releaseYear": "2010"},
9-
{ "title": "Interstellar", "releaseYear": "2014"}
5+
{ "id": "1", "title": "Star Wars", "releaseYear": "1977"},
6+
{ "id": "2", "title": "Back to the Future", "releaseYear": "1985"},
7+
{ "id": "3", "title": "The Matrix", "releaseYear": "1999"},
8+
{ "id": "4", "title": "Inception", "releaseYear": "2010"},
9+
{ "id": "5", "title": "Interstellar", "releaseYear": "2014"}
1010
]
1111
}
1212

0 commit comments

Comments
 (0)