Error: Creating a state object during composition without using remember [UnrememberedMutableState from androidx.compose.runtime]

Viewed 22

In my code I call a composable function:

ShowSomeComposable(
    modifier = Modifier,
    isActive = mutableStateOf(true),
) 

and I can compile this and run locally. But the Lint check on my CI system complains:

myFile.kt:147: Error: Creating a state object during composition without using remember [UnrememberedMutableState from androidx.compose.runtime] isActive = mutableStateOf(true),

So how can I replace?

1 Answers

Why do you need to use a mutableState here and not a simple boolean?

I mean, most of the time, when I use a mutableStateOf, I use it in a viewModel or directly inside the composable function. For instance :

var boolean by mutableStateOf(true)
Related