Viewability examples

Summary:
# Changelog:
[Internal][Added] - Provide more props to SectionList examples

Reviewed By: kacieb

Differential Revision: D27100891

fbshipit-source-id: 10e83ca16badf18e8218557aff1ee8a7a86e8c54
This commit is contained in:
Luna Wei
2021-03-18 11:33:32 -07:00
committed by Facebook GitHub Bot
parent 8f2c51bde3
commit c357cb4bbf
@@ -224,8 +224,10 @@ export function SectionList_withSeparators(): React.Node {
export function SectionList_onViewableItemsChanged(props: {
viewabilityConfig: ViewabilityConfig,
offScreen?: ?boolean,
horizontal?: ?boolean,
}): React.Node {
const {viewabilityConfig} = props;
const {viewabilityConfig, offScreen, horizontal} = props;
const [output, setOutput] = React.useState('');
const exampleProps = {
onViewableItemsChanged: info =>
@@ -236,13 +238,15 @@ export function SectionList_onViewableItemsChanged(props: {
.join(', '),
),
viewabilityConfig,
horizontal,
};
return (
<SectionListExampleWithForwardedRef
exampleProps={exampleProps}
testOutput={output}
/>
testOutput={output}>
{offScreen === true ? <View style={styles.offScreen} /> : null}
</SectionListExampleWithForwardedRef>
);
}
@@ -251,6 +255,7 @@ type Props = {
onTest?: ?() => void,
testLabel?: ?string,
testOutput?: ?string,
children?: ?React.Node,
};
const SectionListExampleWithForwardedRef = React.forwardRef(
@@ -274,6 +279,7 @@ const SectionListExampleWithForwardedRef = React.forwardRef(
) : null}
</View>
) : null}
{props.children}
<SectionList
ref={ref}
testID="section_list"
@@ -340,4 +346,7 @@ const styles = StyleSheet.create({
flex: 1,
},
container: {flex: 1},
offScreen: {
height: 1000,
},
});