I use scalajs-react and cannot understand why it does not work
please help, it seems to be easy
<.dev()(^.onClick ==> {(e: ReactEventFromHtml) => handler(e)})
def handler(e: ReactEventFromHtml): Callback = {
Callback {
val elem = e.target //here we get elem = null
//----- any code ----
}
}
React re-uses events once it thinks you're finished with them.
Try either
.persist
on the event to prevent React from re-using itCallback
. I'll give two examples of how to do that: