How to get Input Value in Rescript?

How to get Input Value in Rescript? as we change the way of accessing object ##, I have no ide how to get the value out of element?

Though this may general question of how accessing object, because in rescript I think like we must do Rescript’s way, otherwise, the compiler will log error.

 The record field value can't be found.
  If it's defined in another module or file, bring it into scope by:
  - Prefixing it with said module name: TheModule.value
  - Or specifying its type: let theValue: TheModule.theType = {value: VALUE}

object access syntax in rescript is

let value = obj["key"];

simple input example with react:

let make = () => {
  let (text, setText) = React.useState(() => "")

  let handleInputChange = event => {
    let value = ReactEvent.Form.currentTarget(event)["value"]

    setText(_ => value)

  <input type_="text" value={text} onChange={handleInputChange} />


You can paste any ReasonML syntax snippet and get its equivalent ReScript syntax in the ReScript playground. Go to the ‘Settings’ tab and flip the syntax from RES to RE and back to RES after pasting the snippet. It will auto-convert.

1 Like