Fix flowfixme in ScrollViewExample

Summary:
$title

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D17949318

fbshipit-source-id: 9daa8890d4a65678c6ebf800b1c66d4ed2f4d80f
This commit is contained in:
Eli White 2019-10-22 14:07:48 -07:00 коммит произвёл Facebook Github Bot
Родитель cc056907cf
Коммит 7d8dfa500c
1 изменённых файлов: 10 добавлений и 12 удалений

Просмотреть файл

@ -21,6 +21,8 @@ const {
View, View,
} = require('react-native'); } = require('react-native');
const nullthrows = require('nullthrows');
import type {ViewStyleProp} from '../../../../Libraries/StyleSheet/StyleSheet'; import type {ViewStyleProp} from '../../../../Libraries/StyleSheet/StyleSheet';
exports.displayName = 'ScrollViewExample'; exports.displayName = 'ScrollViewExample';
@ -33,12 +35,11 @@ exports.examples = [
description: description:
'To make content scrollable, wrap it within a <ScrollView> component', 'To make content scrollable, wrap it within a <ScrollView> component',
render: function(): React.Node { render: function(): React.Node {
let _scrollView: ScrollView; let _scrollView: ?React.ElementRef<typeof ScrollView>;
return ( return (
<View> <View>
<ScrollView <ScrollView
ref={scrollView => { ref={scrollView => {
// $FlowFixMe Invalid prop usage
_scrollView = scrollView; _scrollView = scrollView;
}} }}
automaticallyAdjustContentInsets={false} automaticallyAdjustContentInsets={false}
@ -52,19 +53,19 @@ exports.examples = [
<Button <Button
label="Scroll to top" label="Scroll to top"
onPress={() => { onPress={() => {
_scrollView.scrollTo({y: 0}); nullthrows(_scrollView).scrollTo({y: 0});
}} }}
/> />
<Button <Button
label="Scroll to bottom" label="Scroll to bottom"
onPress={() => { onPress={() => {
_scrollView.scrollToEnd({animated: true}); nullthrows(_scrollView).scrollToEnd({animated: true});
}} }}
/> />
<Button <Button
label="Flash scroll indicators" label="Flash scroll indicators"
onPress={() => { onPress={() => {
_scrollView.flashScrollIndicators(); nullthrows(_scrollView).flashScrollIndicators();
}} }}
/> />
</View> </View>
@ -80,7 +81,7 @@ exports.examples = [
title: string, title: string,
additionalStyles: ViewStyleProp, additionalStyles: ViewStyleProp,
) { ) {
let _scrollView: ?ScrollView; let _scrollView: ?React.ElementRef<typeof ScrollView>;
return ( return (
<View style={additionalStyles}> <View style={additionalStyles}>
<Text style={styles.text}>{title}</Text> <Text style={styles.text}>{title}</Text>
@ -96,22 +97,19 @@ exports.examples = [
<Button <Button
label="Scroll to start" label="Scroll to start"
onPress={() => { onPress={() => {
// $FlowFixMe Invalid prop usage nullthrows(_scrollView).scrollTo({x: 0});
_scrollView.scrollTo({x: 0});
}} }}
/> />
<Button <Button
label="Scroll to end" label="Scroll to end"
onPress={() => { onPress={() => {
// $FlowFixMe Invalid prop usage nullthrows(_scrollView).scrollToEnd({animated: true});
_scrollView.scrollToEnd({animated: true});
}} }}
/> />
<Button <Button
label="Flash scroll indicators" label="Flash scroll indicators"
onPress={() => { onPress={() => {
// $FlowFixMe Invalid prop usage nullthrows(_scrollView).flashScrollIndicators();
_scrollView.flashScrollIndicators();
}} }}
/> />
</View> </View>