LoginSignup
6
5

More than 5 years have passed since last update.

[React Native]FlatListを更新する方法

Last updated at Posted at 2019-02-17

React Nativeのバージョンは0.57.8。

以下のようにextraDataを設定しておく。

<FlatList
  data={...}
  extraData={this.state.refreshFlatList}
  renderItem={this.renderItem.bind(this)}
  keyExtractor={(item, index) => index.toString()}
/>

初期化の際の値はどちらでも可。

constructor(props) {
  super(props);
  this.state = {refreshFlatList: true};

リストを更新したいタイミングで値を反転する。

this.setState({refreshFlatList: !this.state.refreshFlatList});

参考

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5