compose-lints icon indicating copy to clipboard operation
compose-lints copied to clipboard

False positive for ComposeModifierReused

Open ansman opened this issue 1 year ago • 1 comments

Here is an example:

@Composable
fun Example(
    modifier: Modifier = Modifier,
    content: @Composable BoxScope.() -> Unit,
) {
    val context = LocalContext.current
    val currentContent by rememberUpdatedState(content)
    val currentModifier by rememberUpdatedState(modifier)
    val overlayView = remember {
        ComposeView(context).apply {
            setContent {
                Box(currentModifier.fillMaxSize(), content = currentContent)
            }
        }
    }
    DisposableEffect(overlayView) {
        onDispose {}
    }
}

I'm seeing a lint error on both the Box as well as the DisposableEffect saying that composable modifiers shouldn't be reused. Commenting out either removes the error.

ansman avatar Mar 03 '24 18:03 ansman

That's strange. Does that reproduce in a test?

ZacSweers avatar Mar 04 '24 00:03 ZacSweers