onSubmitted

Specification

Called immediately in case asynchronous submit action resolves.

Definition

1
type OnSubmitted = ({
2
res: Response, // Accumulated response from the async submit action
3
serialized: Object, // Serialized fields
4
fields: Object, // The state of the fields
5
form: ReactComponent // Reference to the Form component
6
}) => void
Copied!

Example

1
import React from 'react'
2
import { Form } from 'react-advanced-form'
3
import { Input } from 'react-advanced-form-addons'
4
5
export default class RegistrationForm extends React.Component {
6
handleUserRegistered = ({ res, serialized, fields, form }) => {
7
// ...
8
}
9
10
render() {
11
return (
12
<Form onSubmitted={this.handleUserRegistered}>
13
<Input name="username" required />
14
<button type="submit">Submit</button>
15
</Form>
16
)
17
}
18
}
Copied!
Note: It's a good practice to name the onSubmitted callback methods relatively to the form's primary action. For "Registration" form - onUserRegistered, for "Add product to Cart" form - onProductAdded, etc.
Last modified 3yr ago