프로그래밍/안드로이드+코틀린
Jetpack Compose getValue, setValue 에러
이원중
2021. 8. 19. 08:47
반응형
remember와 mutableStateof를 이용해서 변수를 설정해주려고 하는데 위와 같은 오류가 발생했다.
오류 내용은 아래와 같다.
Type 'TypeVariable(T)' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
또는 아래와 같을 수 있다.
Type 'TypeVariable(T)' has no method 'setValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
getValue와 setValue가 설정되지 않아서 발생하는 문제인데 아래 두 코드로 해결해줄 수 있다.
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
아니면 그냥 아래와 같이 전체를 다 import해줘도 된다.
import androidx.compose.runtime.*
반응형