0

I'm using react with javascript along with a library called Unform (( https://github.com/Rocketseat/unform )

I have a form with a single field and I wanted to clear this field after clicking "send".

<Form onSubmit={handleSubmit} >
      <Input
        id="input"
        name="value"
        placeholder="Where are we going?"
      /><br />
      <button
        type="submit"
        class="btn-send-direction"
      >Send Direction</button>
    </Form>

I'm not getting anything that works, can someone who has already done it help me? Thanks!

  • The codesandbox linked at the very start of the docs shows how to do exactly that using `reset()`: https://codesandbox.io/embed/agitated-tdd-uf177?autoresize=1&expanddevtools=1&fontsize=14&hidenavigation=1&theme=dark It's also explained here: https://unform.dev/guides/reset-form –  Jan 19 '22 at 12:09
  • if its react , just give state value to text box and when you press enter clear the state value – midhun k Jan 19 '22 at 12:20
  • @midhunk This is what you'd do if you manage the form state yourself. OP is using unform, which is whey they're asking how to do it. –  Jan 19 '22 at 13:19
  • That was exactly it @Chris G, it worked! Thank you very much! – João Pedro Jan 19 '22 at 14:43

0 Answers0