React-native: FlatList get refs to scroll

Viewed 20127

I'm currently building an app with react native:

this is my flatlist:

    <FlatList
      ref={"myFlatList"}
      data={data}
      keyExtractor={this._keyExtractor}
      renderItem={this._renderItem}
    />

In this function I want to scroll to a specific index:

  _enableTVEventHandler() {
    this._tvEventHandler = new TVEventHandler();
    this._tvEventHandler.enable(this, function(cmp, evt) {
        this.refs["myFlatList"].scrollToIndex({viewPosition: 0.5, index: 2});
    }.bind(this));
  }

But I have an error: Cannot read property 'scrollToIndex' of undefined

1 Answers
Related