Type 'State<List?>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
아래의 두가지 상황일 경우, 에러 발생
Code
@Composable
fun UserScreen(userViewModel:UserViewModel){
val items: List<User> by userViewModel.fetchUserList.observeAsState()
UserList(userList = items)
}
@Composable
fun UserScreen(){
var value by remember { mutableStateOf("") }
}
방법1
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
방법2
// for a 'val' variable
import androidx.compose.runtime.getValue
// for a `var` variable also add
import androidx.compose.runtime.setValue
// or just
import androidx.compose.runtime.*