import React, { Component } from 'react';
import { Alert, AppRegistry, FlatList, Text, TextInput, View } from 'react-native';
export default class PizzaTranslator extends Component {
constructor(props) {
super(props);
this.state = {text: ''};
}
_onload() {
this.abc.scrollTo({x: 0, y: 0, animated: true});
}
render() {
return (
<View>
<FlatList
data={[
{key: 'Devin'},
{key: 'Jackson'},
{key: 'James'},
{key: 'Joel'},
{key: 'John'},
{key: 'Jillian'},
{key: 'Jimmy'},
{key: 'Julie'},
{key: 'Devin'},
{key: 'Jackson'},
{key: 'James'},
{key: 'Joel'},
{key: 'John'},
]}
renderItem={({item}) => <Text>{item.key}</Text>}
onScrollBeginDrag={this._onload}
ref={(FlatList) => {this.abc = FlatList;}}
/>
</View>
);
}
}
// skip this line if using Create React Native App
AppRegistry.registerComponent('AwesomeProject', () => PizzaTranslator);
Как мне использовать метод scrollTo? как это вообще работает?