0

After doing a bit of research this is the closest answer i could get but this isnot for scenarioes where we have rowsWithSection. React-Native Updating List View DataSource

The Problem i am facing is Something like this; The users first goes to contacts list and then they drill down to see a specific contact detail and they can modify it; assume they modified the name of the person ; now when they navigate back the list view; the listView should be refreshed and updated; but since my listView has Sections the previous example was not straight forward and i couldn't get my head around the solution provided. picture of Contacts List and Detail

the structure of my dataset i am passing to my listView looks like this:

       {'a':[{},{}], b:[{}]}

if any one has done such a thing pleaseeee help.

Thank you!

Community
  • 1
  • 1
Derese Getachew
  • 440
  • 6
  • 10

2 Answers2

0

the way i solved this problem is rather than editing; i delete it from the dataset and update the dataset first and then add the updated one and update the dataset back again.

Derese Getachew
  • 440
  • 6
  • 10
0

If you do edit the contact it should result in a new row...you store values should be immutable. If you create a new contact row for the ListView it should update.

This also depends on your rowHasChanged declaration. I use the default method provided in the documentation:

rowHasChanged: (r1, r2) => r1 !== r2

The !== is checking if the r1 and r2 are the same reference. Therefore by having an immutable store value and update to it would actually create a new object, r1 and r2 wouldn't be equal and therefore your ListView will update.

SomethingOn
  • 9,813
  • 17
  • 68
  • 107