React Native ListView 長按刪除

項目中React NativeListView的長按刪除功能分享(基于ES5):

/**

*?Sample?React?Native?App

*?https://github.com/facebook/react-native

*?@flow

*/

importReact,?{Component}?from'react';

import{

AppRegistry,

StyleSheet,

Text,

View,

ListView,

TouchableOpacity

}?from'react-native';

vards?=newListView.DataSource({

rowHasChanged:?(r1,?r2)?=>?{

r1?!==?r2

}

});

varrows?=?['row?1','row?2','row?3','row?4','row?5','row?6'];

varXXX?=?React.createClass({

getInitialState()?{

return{

dataSource:?ds.cloneWithRows(rows),

};

},

_deleteRow(rowID)?{

deleterows[rowID];

this.setState({dataSource:?ds.cloneWithRows(rows)})

},

renderRow(rowData,?sectionID,?rowID)?{

returnthis._deleteRow(rowID)}

style={{height:?60,?flex:?1,?borderBottomWidth:?1}}>

{rowData}

},

render()?{

return(

dataSource={this.state.dataSource}

renderRow={this.renderRow}

/>

);

}

});

AppRegistry.registerComponent('XXX',?()?=>?XXX);

本文原創地址:http://blog.csdn.net/chichengjunma/article/details/53331160

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容