React Advanced Form is a library for tailoring real-world forms in React with pleasure and ease.
Features
Expectations shift
Trust and expect a form to do more than just rendering the fields. Our features are designed to handle cumbersome use cases with clean and performant code
Immutable
Each field interaction or update is a pure function that produces the next state of a field.
React Advanced Form is field-centric. That means you define flexible fields composites and reuse them throughout the application. Reflect even the most granular field state changes in the UI to achieve the outmost user experience.
Develop production-ready forms in a speed of a prototype.
// This is not a diminished example, this is a finite form<Form action={this.registerUser}> <Input name="username" required /> <Input name="password" type="password" required /></Form>
Select fields and declare validation rules using resolver functions. Utilize the order and priority of their execution to craft validation logic of any complexity.
export default { type: { password: { capitalLetter: ({ value }) => /[A-Z]/.test(value), oneNumber: ({ value }) => /[0-9]/.test(value), }, }, name: { confirmPassword: ({ get, value }) => { /** * The "confirmPassword" field will be re-validated whenever * the "value" prop of "userPassword" field updates. */ return value === get(['userPassword', 'value']) }, },}
Each validation resolver can access respective field's value, fieldProps, and the form as the parameters. It can also reference other field's state via the get function, which creates a props subscription to re-evaluate the respective validation rule in real time.
Say goodbye to crowdedvalidatefunctions, welcome clean validation schema!
How much effort would it take you to make one field required based on another field(s)? Yes, the correct answer is—one line of code:
<Input name="firstName" required={({ get }) => !!get(['lastName', 'value'])} /><Input name="lastName" required={({ get }) => !!get(['firstName', 'value'])} />
Get as many data from the sibling fields as needed, and build your logic around that. Rely on reactive programming that will re-evaluate a resolver function whenever the referenced field props update.
React Advanced Form can be used with any third-party fields library by using powerful createField API. It also allows to create custom fields from literally any component.
Getting started
Install
npm install react-advanced-form --save
Make sure to have React (15.0+) installed in your project.
Guidelines
Starting with something new may appear challenging. We have prepared step-by-step instructions on how to Get started with React Advanced Form to make the adoption process clear and fast.
Any of your contributions are highly appreciated. Please read through the Contribution guidelines beforehand. Development isn't the only way to support, there are many more.