React-native-draggable-flatlist: when performing an update on the content, this does not reflect for the listing

Created on 12 Nov 2018  路  5Comments  路  Source: computerjazz/react-native-draggable-flatlist

I am updating the content of DraggableFlatList, in the data attribute via redux, but I noticed that when updating in the variable that is defined in the date, it does not update the listing, this only occurs when the drag drop

Example with DraggableFlatList:

com draggableflatlist

code:

<DraggableFlatList
        data={data}
        renderItem={this.renderItem}
        keyExtractor={item => `key-${item.interno}`}
        scrollPercent={5}
        onMoveEnd={({ data }) => this.props.ordenacaoActions.setOrderUnidadesRequest({ data })}
        contentContainerStyle={{ marginHorizontal: metrics.baseMargin }}
        ItemSeparatorComponent={() => <View style={styles.separator} />}
      />

Example without DraggableFlatList and use original FlatList

flatlist

code:

<FlatList
        data={data}
        renderItem={this.renderItem}
        keyExtractor={item => `key-${item.interno}`}
        scrollPercent={5}
        onMoveEnd={({ data }) => this.props.ordenacaoActions.setOrderUnidadesRequest({ data })}
        contentContainerStyle={{ marginHorizontal: metrics.baseMargin }}
        ItemSeparatorComponent={() => <View style={styles.separator} />}
      />

I believe the lib, is not considering in your shouldComponentUpdate when there is update in the input values, or something of the genre ...

Am I correct about this procedure?

Most helpful comment

I solved this using @bomei's suggestion. Passing the prop extraData with the nested data that can change resolved the issue for me. Check out the docs on this prop here: https://facebook.github.io/react-native/docs/flatlist#extradata

It might be clearer if we added a link in the readme to all the FlatList props you can pass so we avoid confusion in the future: https://facebook.github.io/react-native/docs/flatlist#props

All 5 comments

FlatList is pureComponent, you should add extraData={data} or something similar in your code.

Is there any update on this problem as still having this issue

I solved this using @bomei's suggestion. Passing the prop extraData with the nested data that can change resolved the issue for me. Check out the docs on this prop here: https://facebook.github.io/react-native/docs/flatlist#extradata

It might be clearer if we added a link in the readme to all the FlatList props you can pass so we avoid confusion in the future: https://facebook.github.io/react-native/docs/flatlist#props

yep, extraData seems like the answer here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dev-sathish picture dev-sathish  路  7Comments

ymohdriz picture ymohdriz  路  7Comments

soumyamishra89 picture soumyamishra89  路  10Comments

chriszwickerocteris picture chriszwickerocteris  路  9Comments

rassemdev picture rassemdev  路  11Comments