Skip to content

Instantly share code, notes, and snippets.

@FSPinho
Created April 16, 2022 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FSPinho/bb62711db8d7f375133a3e3523538f1c to your computer and use it in GitHub Desktop.
Save FSPinho/bb62711db8d7f375133a3e3523538f1c to your computer and use it in GitHub Desktop.
Speedy List Dynamic Item Height Example
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