React-native-swipe-list-view: Close opened row is there any other ways when delete one row in listview?

Created on 31 Oct 2016  路  9Comments  路  Source: jemise111/react-native-swipe-list-view

@jemise111
when I open one row ,there is a delete-button .And I touch button to delete this row,its not closed when row in not end of listview .

Now ,how to close row which be opened voluntarily,not press to close and slide to close.Thanks

Most helpful comment

I know this is somewhat late but if anyone is still experiencing this issue, it's because the key that is used to identify the row is not correctly defined. Make sure if you are using the keyExtractor that it is not returning an undefined value or something

All 9 comments

1
1
2
2
3
3

Hey @sharingjingang050241 hm I'm not sure what's going. If you follow the SwipeListExample/example.js file it's working just fine with deleting rows and closing the deleted ones. Here's a GIF to show what the behavior is in the example:

If you still can't get it to work please reopen this issue and paste some code you're using to do the deleting, and I'll be happy to take a closer look, thanks!

I have same issue.I used SwipeRow in my project.Another solution that i found is to use SwipeListView.But sometime it creates problem in rendering rows.Sometimes some of rows getting rendered and other portion of the screen remains blank.When I just scroll,all rows getting rendered.So I avoid to use that solution and remains on SwipeRow to render my list.

Please any one can help?

@sharingjingang050241 just set ref={'swipeListView'} in SwipeListView, and call this.refs.swipeListView.safeCloseOpenRow(); when you Press on Delete Button

I know this is somewhat late but if anyone is still experiencing this issue, it's because the key that is used to identify the row is not correctly defined. Make sure if you are using the keyExtractor that it is not returning an undefined value or something

hey @lamStephan, I still face this problem. keyExtractor I got from index so can not be undefined or something but still not working! Please help!

Hey @thanhluantl2304, haven't worked with this library in some time. Mainly because it tends to be hard for users to identify this feature unless it is specifically shown to them.

This is purely based on memory and if you can provide a code snippet that will be helpful. I think what's happening is that when the user opens a list item the framework uses the key to know what item is open after a state update. The problem with this and using the index as a key is that when the item is removed the index values change for all the items below that deleted row. So when the state updates the lower row gets the old index of the deleted item. Meaning the framework still believes that the delete row exists and it should be kept open.

Short answer: Use the keyExtractor but use unique values and not the index of the item. Maybe a id. If I remember correctly, my list did not have unique ids so what i did was use the Math.random + the index. Try to avoid this since you'll lose references to the rows and can really do anything to them with your code (I think).

Ok, i got this. You saved my life! Thank you very much!^^

@IamStephan fixed the row closing issue thanks to you. There is also another problem I am facing. Deleting the last row leaves a little of the deleted row hidden delete button. It show like a little line. I have attached the image. Please give them a look. Look at the the little red line that stays after the item is deleted.

Screenshot_20200910-161325

Screenshot_20200910-161331

Was this page helpful?
0 / 5 - 0 ratings