This repository was archived by the owner on Mar 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +66
-12
lines changed Expand file tree Collapse file tree 2 files changed +66
-12
lines changed Original file line number Diff line number Diff line change @@ -96,10 +96,52 @@ import SocialIcon from 'HSSocialIcon'
96
96
import List from 'HSList'
97
97
import ListItem from 'HSListItem'
98
98
99
- // Can also replace map function with RN ListView implementation
99
+
100
+ ```
101
+
102
+ <List >
103
+ {
104
+ list1.map((l, i) => (
105
+ <ListItem
106
+ key={i}
107
+ onPress={log}
108
+ title={l.title}
109
+ icon={{name: l.icon}}
110
+ />
111
+ ))
112
+ }
113
+ </List >
114
+
115
+ ```
116
+
117
+
118
+ // With RN ListView implementation
119
+
120
+ renderRow (rowData, sectionID) {
121
+ return (
122
+ <ListItem
123
+ key={sectionID}
124
+ onPress={log}
125
+ title={rowData.title}
126
+ icon={{name: rowData.icon}}
127
+ />
128
+ )
129
+ }
130
+
131
+ render () {
132
+ return (
133
+ <List>
134
+ <ListView
135
+ renderRow={this.renderRow}
136
+ dataSource={this.state.dataSource}
137
+ />
138
+ </List>
139
+ )
140
+ }
141
+
100
142
<List>
101
143
{
102
- list2 .map((l, i) => (
144
+ list .map((l, i) => (
103
145
<ListItem
104
146
roundAvatar
105
147
avatar={l.avatar_url}
Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react'
2
- import { View , StyleSheet , ScrollView } from 'react-native'
2
+ import { View , StyleSheet , ScrollView , ListView } from 'react-native'
3
3
import Text from 'HSText'
4
4
import Icon from 'react-native-vector-icons/MaterialIcons'
5
5
import ListItem from 'HSListItem'
@@ -60,6 +60,24 @@ const list2 = [
60
60
]
61
61
62
62
class More extends Component {
63
+ constructor ( ) {
64
+ super ( )
65
+ const ds = new ListView . DataSource ( { rowHasChanged : ( r1 , r2 ) => r1 !== r2 } )
66
+ this . state = {
67
+ dataSource : ds . cloneWithRows ( list1 )
68
+ }
69
+ this . renderRow = this . renderRow . bind ( this )
70
+ }
71
+ renderRow ( rowData , sectionID ) {
72
+ return (
73
+ < ListItem
74
+ key = { sectionID }
75
+ onPress = { log }
76
+ title = { rowData . title }
77
+ icon = { { name : rowData . icon } }
78
+ />
79
+ )
80
+ }
63
81
render ( ) {
64
82
return (
65
83
< ScrollView style = { styles . mainContainer } >
@@ -68,16 +86,10 @@ class More extends Component {
68
86
< Text style = { styles . heading } > List</ Text >
69
87
</ View >
70
88
< List >
71
- {
72
- list1 . map ( ( l , i ) => (
73
- < ListItem
74
- key = { i }
75
- onPress = { log }
76
- title = { l . title }
77
- icon = { { name : l . icon } }
89
+ < ListView
90
+ renderRow = { this . renderRow }
91
+ dataSource = { this . state . dataSource }
78
92
/>
79
- ) )
80
- }
81
93
</ List >
82
94
< List containerStyle = { { marginBottom : 20 } } >
83
95
{
You can’t perform that action at this time.
0 commit comments