# MutableState

Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/SnapshotState.kt+class:androidx.compose.runtime.MutableState) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0) Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  interface MutableState<T : Any?> : State<T>
  ```
Known direct subclasses [MutableDoubleState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableDoubleState), [MutableFloatState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableFloatState), [MutableIntState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableIntState), [MutableLongState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableLongState), [ProduceStateScope](https://developer.android.com/reference/kotlin/androidx/compose/runtime/ProduceStateScope), [SnapshotMutableState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotMutableState)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableDoubleState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableDoubleState#doubleValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableFloatState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableFloatState#floatValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableIntState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableIntState#intValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableLongState` | A value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableLongState#longValue()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function cause the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` to subscribe to changes of that value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ProduceStateScope` | Receiver scope for use with `https://developer.android.com/reference/kotlin/androidx/compose/runtime/produceState.composable#produceState(kotlin.Any,kotlin.coroutines.SuspendFunction1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotMutableState` | A mutable value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotMutableState#value()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function, the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` will be subscribed to changes of that value. |

*** ** * ** ***

A mutable value holder where reads to the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState#value()` property during the execution of a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function, the current `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope` will be subscribed to changes of that value. When the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState#value()` property is written to and changed, a recomposition of any subscribed `https://developer.android.com/reference/kotlin/androidx/compose/runtime/RecomposeScope`s will be scheduled. If `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState#value()` is written to with the same value, no recompositions will be scheduled.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#mutableStateOf(kotlin.Any,androidx.compose.runtime.SnapshotMutationPolicy)` |   |

## Summary

| ### Public functions |
|---|---|---|
| `operator T` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState#component1()()` | Cmn |
| `operator (T) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState#component2()()` | Cmn |

| ### Public properties |
|---|---|---|
| `T` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState#value()` | Cmn |

| ### Extension functions |
|---|---|---|
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState<T>.https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState#(androidx.compose.runtime.MutableState).setValue(kotlin.Any,kotlin.reflect.KProperty,kotlin.Any)( thisObj: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, property: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-property/index.html<*>, value: T )` Permits property delegation of `var`s using `by` for `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState`. | Cmn |

## Public functions

### component1

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
operator fun component1(): T
```

### component2

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
operator fun component2(): (T) -> Unit
```

## Public properties

### value

Cmn

```
var value: T
```

## Extension functions

### MutableState.setValue

Cmn Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/SnapshotState.kt+function:setValue)

```
inline operator fun <T : Any?> MutableState<T>.setValue(
    thisObj: Any?,
    property: KProperty<*>,
    value: T
): Unit
```

Permits property delegation of `var`s using `by` for `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState`.

```kotlin
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember

var count by remember { mutableStateOf(0) }

Text(text = "You clicked $count times")
Button(onClick = { count = count + 1 }) { Text("Click me") }
```