https://kotlinlang.org logo
a

antonioleiva

11/16/2021, 11:56 AM
Hi! Does anyone know what's the use case for the
parent
argument in the 
setContent
 extension?
Copy code
public fun ComponentActivity.setContent(
    parent: CompositionContext? = null,
    content: @Composable () -> Unit
) {...}
I've never seen a sample using this argument 🤔
a

Albert Chang

11/16/2021, 1:35 PM
It can be used to set the content as a child composition. See the source for the explanation of
CompositionContext
. Normally you won’t need to specify this. Here’s an example usage.
a

antonioleiva

11/16/2021, 1:41 PM
oh thanks! Will take a look at this
z

Zach Klippenstein (he/him) [MOD]

11/16/2021, 5:14 PM
Yep Dialog composables use this for example. Ensures that recompositions, composition locals, etc flow from the caller into the Dialog lambda.