https://kotlinlang.org logo
k

Kefas

07/20/2021, 5:34 AM
Hi, let's say that we want to show
SnackCard
which displays only image and its name from a
Snack
object, which one is better:
Copy code
data class Snack(
    val id: Long,
    val name: String,
    val imageUrl: String,
    val price: Long,
    val tagline: String,
    // many other properties
)

// Option 1
@Composable fun SnackCard(snack: Snack) { TODO() }

// Option 2: more optimized for smart recomposition but has more boilerplate
@Composable fun SnackCard(name: String, imageUrl: String) { TODO() }