Hi all, I am migrating a project from muirwik and ...
# react
p
Hi all, I am migrating a project from muirwik and kotiln-react-legacy to kotlin-mui and kotlin-react. I'm trying to fetch targetInputValue when form data is changed but I'm not sure if what I'm doing is the best approach for that. Attached in the thread is a snippet of my previous code and current code.
t
Events are strictly typed. No
unsafeCast
required.
FormEventHandler<HTMLInputElement>
will provide strict
target
if you need typed callback cc @Sergei Grishchenko
Copy code
val onEmailChanged: FormEventHandler<HTMLInputElement> = {
  setEmail(it.target.value)
}
Also it can be inlined
Copy code
onChange = { setEmail(it.target.value) }
p
onChange is expecting
FormEventHandler<HTMLDivElement>
which does not give value directly via target.value
t
Copy code
onChange = { 
    val target = it.target as HTMLInputElement
    setEmail(target.value) 
}
In my cases I use
input
change event