Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
969 views
in Technique[技术] by (71.8m points)

Jetpack Compose - How can we call a @Composable function inside an onClick()

I know its not possible to call composable functions inside onClick. @Composable invocations can only happen from the context of a @Composable function

Compose version - alpha06

But I'm stuck with the below requirement. The requirement is, Call a server api call inside an onClick.

LazyColumnFor(items = list) { reports ->
    Box(Modifier.clickable(
        onClick = {
            //API call
            val liveDataReportsDetails =
                viewModel.getReportDetails("xxxx")
            LiveDataComponentForReportsDetails(liveDataReportsDetails)


        }
    )) {

        ReportListItem(
            item = reports
        )
    }
}
question from:https://stackoverflow.com/questions/65641635/jetpack-compose-how-can-we-call-a-composable-function-inside-an-onclick

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...