Skip to content

Commit

Permalink
flatlist-inverted ex add buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Jul 14, 2022
1 parent c47a75a commit c793c3b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/rn-tester/js/examples/FlatList/FlatList-inverted.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,22 @@ const renderFlatList = ({item}) => <NestedFlatList item={item} />;
function NestedFlatList(props) {
const [items, setItems] = useState(DATA);
const [disabled, setDisabled] = useState(false);
const [index, setIndex] = useState(DATA.length + 1);
return (
<View>
<Button
title="add an item"
onPress={() => setItems([...items, {title: 'new item'}])}
onPress={() => {
setItems([...items, {title: `new item ${index}`}]);
setIndex(index + 1);
}}
/>
<Button
title="prepend an item"
onPress={() => {
setItems([{title: `new item ${index}`}, ...items]);
setIndex(index + 1);
}}
/>
<Button
title="remove an item"
Expand All @@ -91,12 +102,7 @@ function NestedFlatList(props) {
}}
/>
<Text>Flatlist</Text>
<FlatList
inverted
style={{height: 400}}
renderItem={renderItem}
data={items}
/>
<FlatList style={{height: 400}} renderItem={renderItem} data={items} />
</View>
);
}
Expand Down

0 comments on commit c793c3b

Please sign in to comment.