Adding onreset handler to a form

Similar to my blur() question here I’m in need of assistance on how to best add an onreset handler to an html form?

The form element doesn’t have onreset as part of it’s props, so I’m unsure about how to add it.
I’ve tried the webapi package but couldn’t figure out how if that was included there either.

Do you know how to add additional props to existing elements?

Is this what you are looking for?

1 Like

If you must use that property you’re best to add your own binding. You could use addEventListener instead though which rescript-webapi does provide a binding for.

1 Like

This actually turned out to be a good way to achieve this for me. Thanks for the suggestion.

So in my case I needed to add the onReset action to a form and it ended up looking something like this in my markup:

<div>
  {React.cloneElement(
    <form onSubmit={handleSubmit}>
      {formElements}
    </form>,
    {"onReset": handleReset},
  )}
</div>
1 Like