Action performed on the successful submit of the form.
This function is called only when the form is valid.
type Action = (params) => Promise<any>
import React from 'react'
import { Form } from 'react-advanced-form'
import { Input } from 'react-advanced-form-addons'
export default class RegistrationForm extends React.Component {
registerUser = ({ serialized, fields, form }) => {
return fetch('https://back.end/user', {
method: 'POST',
body: JSON.stringify(serialized),
})
}
render() {
return (
<Form action={this.registerUser}>
<Input
name="username"
label="Username"
required />
<Input
name="password"
label="Password"
required />
</Form>
)
}
}
import React from 'react'
import { connect } from 'react-redux'
import { Form } from 'react-advanced-form'
import { Input } from 'react-advanced-form-addons'
import { registerUser } from '@store/user/actions'
class RegistrationForm extends React.Component {
registerUser = ({ serialized, fields, form }) => {
return this.props.registerUser(serialized)
}
render() {
return (
<Form action={this.registerUser}>
<Input
name="username"
label="Username"
required />
<Input
name="password"
label="Password"
required />
</Form>
)
}
}
export default connect(null, { registerUser })(RegistrationForm)