Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive for ComposeModifierReused #291

Open
ansman opened this issue Mar 3, 2024 · 1 comment
Open

False positive for ComposeModifierReused #291

ansman opened this issue Mar 3, 2024 · 1 comment

Comments

@ansman
Copy link

ansman commented Mar 3, 2024

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.

@ZacSweers
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants