<div class='type'>Composable Function</div>


<a id='references'></a>



<h2 id="rememberupdatedstate-newvalue">rememberUpdatedState</h2>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
@Composable
public fun <T> rememberUpdatedState(newValue: T): State<T>
```


`remember` a `mutableStateOf` `newValue` and update its value to `newValue` on each recomposition
of the `rememberUpdatedState` call.

`rememberUpdatedState` should be used when parameters or values computed during composition are
referenced by a long-lived lambda or object expression. Recomposition will update the resulting
`State` without recreating the long-lived lambda or object, allowing that object to persist
without cancelling and resubscribing, or relaunching a long-lived operation that may be expensive
or prohibitive to recreate and restart. This may be common when working with `DisposableEffect`
or `LaunchedEffect`, for example:


`LaunchedEffect`s often describe state machines that should not be reset and restarted if a
parameter or event callback changes, but they should have the current value available when
needed. For example:


By using `rememberUpdatedState` a composable function can update these operations in progress.