gitim / react-native-sortable-list

React Native Sortable List component
MIT License
871 stars 279 forks source link

I am binding the data source using state value, if the state is updated render row not updating. #81

Open rammi44 opened 6 years ago

rammi44 commented 6 years ago

<SortableList style={styles.list} contentContainerStyle={styles.contentContainer} data={this.state.todoItemArray} renderRow={this._renderRow} />

I have given like this. if the "this.state.todoItemArray" is updating but in render row that is not updating, showing previous values only, not happening as we expected..

rammi44 commented 6 years ago

<SortableList style={styles.list} contentContainerStyle={styles.contentContainer} data={this.state.todoItemArray} renderRow={this._renderRow} />


updating state here:

// this.state.todoItemArray.push({ 'Item': item, 'TodoItemstyle': todoItembgStyle });

        this.state.todoItemArray = this.state.todoItemArray.concat({ 'Item': item, 'TodoItemstyle': todoItembgStyle });

Instead of push i am using concat its working....

allanjsx commented 6 years ago

I'm hitting the same issue. If I want to override the state data, the list is not updating.

The list doesn't change if I do this (example):

this.setState({
    data: newData
})

What's the recommended way to work around it?

chaitgoli commented 6 years ago

Have the same issue any update on this issue ?

AVATAR197 commented 5 years ago

I have the same issue, did you find the solution for that?

Nahani commented 4 years ago

Same issue

AVATAR197 commented 4 years ago

@Nahani

Same issue If you are not using expo try this library https://github.com/computerjazz/react-native-draggable-flatlist I had a lot of problems with that functionality in my previous app so I decided to remove it. But hopefully this will help.