Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass multiple objects or values in FlatList extraData

I have a situation where I need to pass both State and Props in the FlatList extraData.

I tried something like this but didn't work.

 <FlatList
      numColumns={1}
      data={this.props.artists}
      renderItem={this.renderArtistItem}
      initialNumToRender={15}
      keyExtractor={item => item.id}
      extraData={(this.state, this.props.league)}
    />

How to do that?

like image 588
m9m9m Avatar asked May 01 '19 08:05

m9m9m


1 Answers

try this:

<FlatList
  numColumns={1}
  data={this.props.artists}
  renderItem={this.renderArtistItem}
  initialNumToRender={15}
  keyExtractor={item => item.id}
  extraData={[this.state, this.props.league]}
/>

As it will work as an array in extra data.

like image 133
virendrasingh bisht Avatar answered Oct 21 '22 05:10

virendrasingh bisht