Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list itemLayoutAnimation documentation page and example #6279

Merged
merged 14 commits into from
Jul 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename flag
  • Loading branch information
MatiPl01 committed Jul 22, 2024
commit 7b1c7a59506d2ff3503869fc1dfe9c114c08c53e
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ListItem = memo(function ({ id, text, onPress }: ListItemProps) {
});

export default function ListItemLayoutAnimation() {
const [layoutAnimationEnabled, setLayoutAnimationEnabled] = useState(true);
const [layoutTransitionEnabled, setLayoutTransitionEnabled] = useState(true);
const [currentTransitionIndex, setCurrentTransitionIndex] = useState(0);
const [items, setItems] = useState(ITEMS);

Expand Down Expand Up @@ -87,7 +87,7 @@ export default function ListItemLayoutAnimation() {
});
}, []);

const transition = layoutAnimationEnabled
const transition = layoutTransitionEnabled
? LAYOUT_TRANSITIONS[currentTransitionIndex]
: undefined;

Expand All @@ -99,10 +99,10 @@ export default function ListItemLayoutAnimation() {
<Text style={styles.infoText}>Layout animation: </Text>
<TouchableOpacity
onPress={() => {
setLayoutAnimationEnabled((prev) => !prev);
setLayoutTransitionEnabled((prev) => !prev);
}}>
<Text style={styles.buttonText}>
{layoutAnimationEnabled ? 'Enabled' : 'Disabled'}
{layoutTransitionEnabled ? 'Enabled' : 'Disabled'}
</Text>
</TouchableOpacity>
</View>
Expand Down Expand Up @@ -132,7 +132,7 @@ export default function ListItemLayoutAnimation() {
renderItem={renderItem}
keyExtractor={(item) => item}
contentContainerStyle={styles.contentContainer}
itemLayoutAnimation={layoutAnimationEnabled ? transition : undefined}
itemLayoutAnimation={layoutTransitionEnabled ? transition : undefined}
layout={transition}
/>

Expand Down