Created
April 16, 2022 12:26
-
-
Save FSPinho/bb62711db8d7f375133a3e3523538f1c to your computer and use it in GitHub Desktop.
Speedy List Dynamic Item Height Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SpeedyList, SpeedyListItemMeta, SpeedyListItemRenderer } from "react-native-speedy-list" | |
const [items] = useState<Array<User>>([{ id: 0, name: "User 001" }, ...]); | |
const itemRenderer = useCallback( | |
({ item, index, height }: SpeedyListItemProps<User>) => { | |
return <Text>{item.name}</Text> | |
}, | |
[] | |
) | |
const itemHeight = useCallback( | |
({ item, index }: SpeedyListItemMeta<User>) => { | |
return item.name.includes("Luiz") ? 192 : 64; | |
}, | |
[] | |
) | |
const itemKey = useCallback( | |
({ item, index }: SpeedyListItemMeta<User>) => { | |
return item.id; | |
}, | |
[] | |
) | |
<SpeedyList<User> | |
items={items} | |
itemRenderer={itemRenderer} | |
itemHeight={itemHeight} | |
itemKey={itemKey} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment