0

I'm new to React and reactstrap and I was wondering how to setup a form that posts to a post-route on submit using the Form-tag. I couldn't find an example in the documentation that did this. So I'm looking for an equivalent of this:

<form action='/signup/insert' method = 'POST'>
    <div class="form-group">
        <input id ='signup' type='text' name='uid' placeholder='Username'><br>
        <input id ='signup' type='password' name='pwd' placeholder='Password'><br>
        <input id ='signup' type='text' name='email' placeholder='E-mail address'><br>
        <button id = 'switch' type='submit'>Sign Up</button>
     </div>
 </form>

And I want something like this:

<Form>
    <FormGroup>
        <Label for="exampleEmail">Email</Label>
        <Input
            type="email"
            name="email"
            id="exampleEmail"
            placeholder="noreply@noreply.com"
        />
    </FormGroup>
    <FormGroup>
        <Label for="examplePassword">Password</Label>
        <Input
            type="password"
            name="password"
            id="examplePassword"
            placeholder="password"
        />
     </FormGroup>
     <Button>Sign Up</Button>
</Form>

Do I have to add this in the button tag? How to do this? My route is by the way already set up, so I just need to post it from here.

Ansjovis86
  • 1,506
  • 5
  • 17
  • 48

1 Answers1

1

Exactly the same way as in your example without Reactstrap. Form component passes any properties that you provide to the <form> tag that gets rendered on your page so this code <Form action='/signup/insert' method='POST'> will work (if your backend is set up to handle the request.

Marek Takac
  • 3,002
  • 25
  • 30