I have the following @composable function:
@Composable
fun MessageCard(msg: Message){
//Elements
}
And have observed that this piece of code :
@Composable
fun Conversation(messages: List<Message>) {
LazyColumn {
for(message in messages){
MessageCard(message)
}
}
}
complains about : @Composable invocations can only happen from the context of a @Composable function
While on the other hand,
@Composable
fun Conversation(messages: List<Message>) {
LazyColumn {
items(messages) { message ->
MessageCard(message)
}
}
}
Works just fine (it's taken from the official google docs).
By changing the LazyColumn into Column, both approaches work.
Looking through the docs it seemed to me like both LazyColumn and Column are composable functions, so what exactly is going on here.
Thanks in advance.