react-native-swipeout
react-native-swipeout copied to clipboard
Swipeout close not works with realm object as datasource
Tested SwipeoutExample and observed close attribute works fine with rows in data.js as dataSource, but whereas when dataSource is realmObject close attribute not works. "close={!(this.state.sectionID === sectionID && this.state.rowID === rowID)}"
import { ListView } from 'realm/react-native';
constructor(props) {
super(props);
var categories = realm.objects('Category');
var ds = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});
this.state = {
//dataSource: ds.cloneWithRows(rows),
dataSource: ds.cloneWithRows(categories),
sectionID: null,
rowID: null,
}
}
render(){
return(
<ListView
dataSource={this.state.dataSource}
renderRow={this._renderRow.bind(this)}
style={styles.items}
/>
);
}
_renderRow(rowData, sectionID, rowID) {
//let rowData = this.state.dataSource.getRow(sectionID, rowID); if ListView is react-native component
let swipeBtns = [
{
text: 'Edit',
backgroundColor: 'blue',
underlayColor: 'rgba(0, 0, 0, 1, 0.6)',
onPress: () => { this.onEdit(rowData) }
}];
return(
<Swipeout right={swipeBtns}
close={!(this.state.sectionID === sectionID && this.state.rowID === rowID)}
rowID={rowID}
sectionID={sectionID}
autoClose = {true}
backgroundColor= 'transparent'
sensitivity = {20}
onOpen={(sectionID, rowID) => {
this.setState({
sectionID,
rowID,
})
}}
/>
);
}
i have same problem too. very strange.
Did anyone found any solution for this ??