deanmcpherson / react-native-sortable-listview

Drag drop capable wrapper of ListView for React Native
MIT License
918 stars 235 forks source link

How to save the drag and drop status? #24

Closed NancyZY closed 8 years ago

NancyZY commented 8 years ago

with Example.js, It is well done work. but I have a problem ,how to save status for draged listview. In another word, when I quit the app and then enter the app again ,I can see last draged ListView.I konw it may need to AsyncStorage to save the sorted ListView, but how in Example.js ? Hope you give me some advice

deanmcpherson commented 8 years ago

Hi @NancyZY,

If you wanted the order to persist through restarting the app, you will need to use AsyncStorage. It would look something like this https://gist.github.com/deanmcpherson/83d22b894292a7718004d280cb4b9765

NancyZY commented 8 years ago

@deanmcpherson ,Thank you very much. It helps me a lot. And I still have a question , Why I am work with DataSource, renderRow will cannot get the row parameter, when I debugger the code ,I found it direct to dataSource: ``` new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2, }),

 Does the renderRow perform after  setState for DataSource?  In my opinion, I don't think it could be . perhaps my code was wrong in somewhere
deanmcpherson commented 8 years ago

Hey @NancyZY, sorry, I'm not sure what you're asking here.

NancyZY commented 8 years ago

There are some issues for the projects: 1) run your persistedExample.js , the app will 'remember' the status of changed list, That's alright. But it will not drag and drop correctly, you can try it .

2)Another problem is : when data put in the ListView , then like your persistedExample.js to save the data ,but in renderRow will killed , renderRow={row => }

deanmcpherson commented 8 years ago

Fixed in update.