Question about State . Why does’t the second way w...
# compose
f
Question about State . Why does’t the second way work? 1. Work:
Copy code
var refreshing by remember { mutableStateOf(false) }
LaunchedEffect(refreshing) {
    if (refreshing) {
        delay(2000)
        refreshing = false
    }
}

SwipeRefresh(
    state = rememberSwipeRefreshState(isRefreshing = refreshing),
    onRefresh = { refreshing = true },
) { ... }
2. Can’t enter refreshing state:
Copy code
val state = rememberSwipeRefreshState(isRefreshing = false)

LaunchedEffect(state.isRefreshing) {
    if (state.isRefreshing) {
        delay(2000)
        state.isRefreshing = false
    }
}

SwipeRefresh(
    state = state,
    onRefresh = { state.isRefreshing = true },
) { ... }
Why can’t I just use the “isRefreshing” state of SwipeRefreshState and should create another state as the first snippet?