deanmcpherson / react-native-sortable-listview

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

List is not updating when data source is changed #17

Closed andregoncalvesdev closed 8 years ago

andregoncalvesdev commented 8 years ago

List is not updating when data source is changed

On SortableListView, data = { this.state.data }. When i add a list item on another view, the state gets updated and the list dont update.

deanmcpherson commented 8 years ago

Hey @andregoncalvesdev can you provide a code example of your issue?

superandrew213 commented 8 years ago

@andregoncalvesdev I had the same problem. Try my fork if you still need this. Essentially it just removes:

shouldComponentUpdate: function(props) {
     if (props.hovering !== this.props.hovering) return true;
     if (props.active !== this.props.active) return true;
     if (props.rowData.data !== this.props.rowData.data) return true;
     return false;
   },
deanmcpherson commented 8 years ago

Thanks @superandrew213, the shouldComponentUpdate method is pretty important for bearable performance, especially on longer lists. Perhaps we should add a rowHasChanged property to all users to implement their own row comparisons.

superandrew213 commented 8 years ago

@deanmcpherson sounds good! I'll submit a PR when I get to it if you haven't done it yet. I just needed it to update for now.

CaleyD commented 8 years ago

It looks like this work as expected if you use an immutable collection of immutable data objects

deanmcpherson commented 8 years ago

Implemented in 0.1.0