79521013

Date: 2025-03-19 17:59:55
Score: 1
Natty:
Report link

React is using synthetic events, so you won't be able to access them with the normal webapis.

let addTodo = evt => {
  ReactEvent.Form.preventDefault(evt)
  let formElem = ReactEvent.Form.currentTarget(evt) // type is {..} which is a record
  let value = formElem["0"]["value"] // access the values on the record
 // do stuff with value
}

playground link: https://rescript-lang.org/try?version=v12.0.0-alpha.9&module=esmodule&code=LYewJgrgNgpgBAQQA5LgXjgbwFBzgAQCcYBDAYwBcA6MkYJEAOxkYtzlgrmBIGt4MACgCU6AHxZ2eTnBJgwAFXAh0cQTABuFAFxwAUgGcAHgFENLagDEQhYFQqi0EnHlccYXAPqrNFALRihqbmrFTWtlRIxCEUACIwAGYk0Gxu0h5wXBi+AUFmFmE2dmQQhMSsCiSEAOYeUq4yGiRQEAKZANoARAAMnQC6XU0tMP3Y9XgAwkwGILBUUCDVgkOtwvUAvmNuADxi43DbABYAjM4ASqSUVAYUhACWjEudAOowULTA8BQqFIfwCgB5WIAxAoTrCdYHAD0Jz2aQOCSKcCYAGUIAAjYB3ChoTByRTKSE3ACesFxF3IcQBAFkqCiKKSYFQePxBAA-MB3AxIKAkYloToJWBGToAGjUwghcPhBweSAgqRleEYJE+Aoo2NgnX2bgZSBgnnVMCMFG1SrwJLJmAplGBtPpjOZfBg7M53N5-M66IWZF4YolEJ1cCh0vh23RCu+jDglpg5MuVPtDLmLJdbJ4NQeABlEjjOgA2JAi8UiKVBvDWhPXW4PJ4IeRwJRgEDgzZK7ZQiMUKOh1wdxG2Xt4I4AJnOVZu90egk6TZABm0rehhzH9Q70s2myAA

Regarding bindings to the webapis, there is an effort to add webapi bindings directly to the language with patterns that work better with ReScript 11+: https://rescript-lang.github.io/experimental-rescript-webapi/

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Josh Derocher-Vlk