Skip to content

Sorting ListView's Datasource Does Not Rerender ListView #555

@cadebward

Description

@cadebward

As far as I can tell, when I sort the dataSource and then call dataSource.cloneWithRows, it thinks nothing has changed, and thus does not rerender the ListView.

Some background:

I fetch some data, which returns: [{price: 10}, {price: 9}...]. After which i set the state with the new data: this.setState({dataSource: this.state.dataSource.cloneWithRows(data)}). Lets pretend this data is completely sorted. If i reverse the data and set the state, it will not rerender: this.setState({dataSource: this.state.dataSource.cloneWithRows(data.reverse())})

BUT: After messing around a bit, i made a change to the dataSource, like so:

// getInitialState...
dataSource: new ListView.DataSource({
  rowHasChanged: (row1, row2) => true,
}),

...which I know is hackery... But now I can toggle reverse back and forth and it works!

Am I missing something here? Or is this perhaps a side effect of the ListView's optimizations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions