I wrote this code. it prevents reloading of the page and then writes something to the log.
let onButtonClick = event => {
ReactEvent.Form.preventDefault(event)
Js.Console.log("Button clicked")
}
@react.component
let make = () => {
<main>
<form className={styles["form"]}>
<input type_="text" placeholder="Top Text" className={styles["form--input"]}/>
<input type_="text" placeholder="Bottom Text" className={styles["form--input"]} />
<button
onClick={onButtonClick}
className={styles["form--button"]}>
{"Get a new Meme image" -> React.string}
</button>
</form>
</main>
}
Rescript compiler is throwing a very cryptic error at me… why is bothered about the “mouse”?
This has type: ReactEvent.Form.t => unit
Somewhere wanted: JsxEvent.Mouse.t => unit
The incompatible parts:
ReactEvent.Form.t (defined as JsxEvent.synthetic<ReactEvent.Form.tag>) vs
JsxEvent.Mouse.t (defined as JsxEvent.synthetic<JsxEvent.Mouse.tag>)
Further expanded:
ReactEvent.Form.tag (defined as JsxEvent.Form.tag) vs
JsxEvent.Mouse.tag