react-native-swipeout icon indicating copy to clipboard operation
react-native-swipeout copied to clipboard

Swipeout close not works with realm object as datasource

Open ugendrang opened this issue 7 years ago • 2 comments

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,
			})
		  }}
		 />
	);
	}

ugendrang avatar Jul 09 '17 08:07 ugendrang

i have same problem too. very strange.

mertpamukcu avatar Jul 16 '17 21:07 mertpamukcu

Did anyone found any solution for this ??

MarioRozic avatar Oct 04 '17 11:10 MarioRozic