Single click handler types accessing DOM Event fields

Greetings,

I want to define a single click handler reference.

let onLinkClick = evt => {/* ??? */}
// [...huge array].map(txt => ...
<a href={txt} onClick=onLinkClick> {string(txt)} </a>

however, as other threads denote, DOM types aren’t legit. Ideally, i’d pull evt.currentTarget.href and send that thru RescriptReactRouter.push (as well as an evt.preventDefault() invocation).

Show me your code snippet!

Playground.

let txt = ""
let onLinkClick = evt => {
  let href = ReactEvent.Mouse.target(evt)["href"]
  Js.log(href)
}
// [...huge array].map(txt => ...
let _ = <a href={txt} onClick=onLinkClick> {React.string(txt)} </a>
1 Like