visit
There are two ways to create forms in angular, one is
template-driven-form
and the other is[reactive-form](//angular.io/guide/reactive-forms)
.Template forms are good but only for the smaller forms but when you have to deal with larger form reactive-forms works like a magic.
Reactive forms or data-driven-form in angular are quite popular and provides a better structured way to build and control your forms.
Now come to the react, it has many third party libraries to control the forms but they all are not much rich in features.
Dependency issues For ex. redux-forms
, depends on redux. So, what if I’m using another state management library or even not using any one.
Today I’m launching [react-reactive-forms](//github.com/bietkul/react-reactive-form.git)
, a library which comes with zero dependency and is same powerful as the reactive forms of angular.It allows to create a tree of form control objects in the component class and bind them with native form control elements.
Zero dependencyIt weighs only 4.6k gzipped, the only peer dependency is react.❤️️
**Nested Forms**It supports nested forms, you can create nested controls by using Form Group
and Form Array
apis.
**Update Options**There is a property called updateOn
by using it you can define the update strategy of a control.
A simple form using react-reactive-form.
Check out this example, a complex user registration form with synchronous, asynchronous validators, nested forms and updateOn
feature.
A complex user registration form with react-reactive-forms. For more details, see the .
updateOn
options for eg. onKeyPress