简体   繁体   中英

How can I make a CameraSelector build class in Jetpack Compose remember to avoid recomposition issue?

I have a build class in Kotlin compose i want to make it remember for avoiding some recompositions issues

val cameraSelector: CameraSelector = CameraSelector.Builder()
    .requireLensFacing(CameraSelector.LENS_FACING_BACK)
    .build()

i found the answer

val cameraSelector = remember {
    CameraSelector.Builder()
        .requireLensFacing(CameraSelector.LENS_FACING_BACK)
        .build()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM