Hello, I'm stuck on this problem. I want to captur...
# react
d
Hello, I'm stuck on this problem. I want to capture all the items a user checked and display them. Why Can't I initialize an empty array?
t
useState
must be called on component level
d
Hello Victor, I tried that as well
image.png
t
You need use state for
selectedChecks
Copy code
var selectedChecks by useState(emptyList<String>())
d
image.png
doesn't have add
t
Copy code
selectedChecks = selectedChecks + item
d
Doesn't add more than one check
t
Copy code
val (selectedChecks, setSelectedChecks) = useState(emptyList<String>())

// ...

onChange = {
    setSelectedChecks { it + item }
}