Currently when using useState() in my react app i ...
# javascript
n
Currently when using useState() in my react app i have to define and integer value as below and it works:
Copy code
val (myValue, setMyValue) = useState(Int.MAX_VALUE)
When i use an Int as below:
Copy code
val (myValue, setMyValue) = useState(Int)
I get an error when trying to access or pass myValue to a function that requires an Int saying:
Type mismatch: Required Int, Found Int.Companion
Can someone help me explain why this is happening and what those two mean?
b
Int -> type Int.MAX_VALUE -> an Int typed static value containing maximum integer that runtime can hold
might be easier to understand with this comparrison:
Copy code
val intValue: Int = Int.MAX_VALUE
val intCompanionType: Int.Companion = Int
👍 1