Hi Community. I am very new to Kotlin JS and new t...
# react
f
Hi Community. I am very new to Kotlin JS and new to React Context. I am trying to use Context like in this example: https://codesandbox.io/s/zk58011yol . I want to have a button inside a component that can update the context of this component. Does someone knows if it is already possible to use useContext() like that and do you maybe have examples?
Copy code
var name by useContext(name1)
t
Dirty example!!!
Copy code
val nameState = useState("My name!")

NameContext(nameState) {
    ... children
}
Usage:
Copy code
var name by useContext(NameContext)
But usually it has sense to use separate context for setter, because you will have new
nameState
(state array) every render
f
Thanks I’ll try to apply this
161 Views