You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -41,79 +41,103 @@ const loginForm = new FormGroup({
41
41
})
42
42
```
43
43
44
+
#### Without initializing the controls ( Dynamic Controls )
45
+
46
+
You can also create controls without even initializing the group control object with the help of new react form components ( [FieldGroup](api/FieldGroup.md), [FieldControl](api/FieldControl.md), [FieldArray](api/FieldArray.md)).
47
+
48
+
For eg.
49
+
50
+
```ts
51
+
<FieldGroup
52
+
render={({ value }) => (
53
+
<form>
54
+
<FieldControl
55
+
name="test"
56
+
render={({ handler }) => <input {...handler()}/>}
57
+
/>
58
+
<pre>{value.toString()}</pre>
59
+
</form>)}
60
+
/>
61
+
```
62
+
The above example will create an instance of [FormGroup](FormGroup.md) class which has a control named `test`.
63
+
64
+
44
65
### step2: Connect form with component
45
-
[Field](api/Field.md) component subscribes a particular control & only update it when it’s or it’s parent’s state changes, which improves the performance by restricting the unnecessary re-rendering of other fields.
66
+
This steps is not needed if you're using dynamic controls but if you want a better control over your form state then you should do that, if your controls are dynamic then you can also initalize the empty group control and add the controls later.
67
+
Example:
46
68
47
69
```js
48
70
importReact, { Component } from'react';
49
-
import { FormBuilder, Validators, Field } from"react-reactive-form";
0 commit comments