@@ -11,14 +11,15 @@ import View from './View';
1111import Button from './Button' ;
1212import Thumbnail from './Thumbnail' ;
1313
14- export default class ListItemNB extends NativeBaseComponent {
14+ var keyIndex = 0 ;
15+
16+ export default class CardItemNB extends NativeBaseComponent {
1517
1618 getInitialStyle ( ) {
1719 return {
1820 listItem : {
1921 borderBottomWidth : this . getTheme ( ) . borderWidth ,
2022 padding : ( this . imagePresent ( ) && ! this . ifShowCase ( ) ) ? 0 : this . getTheme ( ) . listItemPadding ,
21- borderRadius : 1 ,
2223 flex : 1 ,
2324 backgroundColor : this . getTheme ( ) . listBg ,
2425 justifyContent : ( this . buttonPresent ( ) ) ? 'space-between' : 'flex-start' ,
@@ -171,57 +172,67 @@ export default class ListItemNB extends NativeBaseComponent {
171172 if ( child . type == Image && ! Array . isArray ( this . props . children ) ) {
172173 defaultProps = {
173174 resizeMode : 'stretch' ,
174- style : this . getInitialStyle ( ) . fullImage
175+ style : this . getInitialStyle ( ) . fullImage ,
176+ key : keyIndex ++
175177 }
176178 }
177179 else if ( child . type == Button ) {
178180 defaultProps = {
179181 small : true ,
180- style : this . getInitialStyle ( ) . itemButton
182+ style : this . getInitialStyle ( ) . itemButton ,
183+ key : keyIndex ++
181184 }
182185 }
183186 else if ( child . type == Text ) {
184187 if ( ( this . props . header ) || ( this . props . footer ) ) {
185188 defaultProps = {
186- style : this . getInitialStyle ( ) . dividerItemText
189+ style : this . getInitialStyle ( ) . dividerItemText ,
190+ key : keyIndex ++
187191 }
188192 }
189193 else {
190194 if ( child . props . note && this . thumbnailPresent ( ) ) {
191195 defaultProps = {
192- style : this . getInitialStyle ( ) . itemSubNote
196+ style : this . getInitialStyle ( ) . itemSubNote ,
197+ key : keyIndex ++
193198 }
194199 }
195200 else if ( child . props . note ) {
196201 defaultProps = {
197- style : this . getInitialStyle ( ) . itemNote
202+ style : this . getInitialStyle ( ) . itemNote ,
203+ key : keyIndex ++
198204 }
199205 }
200206 else {
201207 defaultProps = {
202- style : this . getInitialStyle ( ) . itemText
208+ style : this . getInitialStyle ( ) . itemText ,
209+ key : keyIndex ++
203210 }
204211 }
205212 }
206213 }
207214 else if ( child . type == Icon ) {
208215 defaultProps = {
209- style : this . getInitialStyle ( ) . itemIcon
216+ style : this . getInitialStyle ( ) . itemIcon ,
217+ key : keyIndex ++
210218 }
211219 }
212220 else if ( child . type == Thumbnail ) {
213221 defaultProps = {
214- style : this . getInitialStyle ( ) . thumbnail
222+ style : this . getInitialStyle ( ) . thumbnail ,
223+ key : keyIndex ++
215224 }
216225 }
217226 else if ( child . type == Image ) {
218227 defaultProps = {
219- style : this . getInitialStyle ( ) . fullImage
228+ style : this . getInitialStyle ( ) . fullImage ,
229+ key : keyIndex ++
220230 }
221231 }
222232 else {
223233 defaultProps = {
224- foregroundColor : this . getContextForegroundColor ( )
234+ foregroundColor : this . getContextForegroundColor ( ) ,
235+ key : keyIndex ++
225236 }
226237 }
227238
@@ -234,13 +245,15 @@ export default class ListItemNB extends NativeBaseComponent {
234245 if ( ( this . props . header ) || ( this . props . footer ) ) {
235246
236247 defaultProps = {
237- style : this . getInitialStyle ( ) . listItemDivider
248+ style : this . getInitialStyle ( ) . listItemDivider ,
249+ key : keyIndex ++
238250 } ;
239251 }
240252
241253 else {
242254 defaultProps = {
243- style : this . getInitialStyle ( ) . listItem
255+ style : this . getInitialStyle ( ) . listItem ,
256+ key : keyIndex ++
244257 } ;
245258 }
246259
@@ -263,7 +276,7 @@ export default class ListItemNB extends NativeBaseComponent {
263276 newChildren = [ ] ;
264277 if ( ! Array . isArray ( this . props . children ) ) {
265278 newChildren . push (
266- < View style = { { justifyContent : 'flex-start' } } >
279+ < View key = { keyIndex ++ } style = { { justifyContent : 'flex-start' } } >
267280 { React . cloneElement ( this . props . children , this . getChildProps ( this . props . children ) ) }
268281 </ View >
269282 ) ;
@@ -273,7 +286,7 @@ export default class ListItemNB extends NativeBaseComponent {
273286 var childrenArray = React . Children . toArray ( this . props . children ) ;
274287 newChildren . push ( React . cloneElement ( childrenArray [ 0 ] , this . getChildProps ( childrenArray [ 0 ] ) ) ) ;
275288 newChildren . push (
276- < View style = { this . notePresent ( ) ? this . getRightStyle ( ) . right : this . squareThumbs ( ) ? this . getRightStyle ( ) . right3 : this . getRightStyle ( ) . right2 } >
289+ < View key = { keyIndex ++ } style = { this . notePresent ( ) ? this . getRightStyle ( ) . right : this . squareThumbs ( ) ? this . getRightStyle ( ) . right3 : this . getRightStyle ( ) . right2 } >
277290 { childrenArray . slice ( 1 ) . map ( ( child ) => {
278291 return React . cloneElement ( child , this . getChildProps ( child ) ) ;
279292 } ) }
0 commit comments