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
Copy file name to clipboardExpand all lines: README.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,8 +15,7 @@
15
15
16
16
* Keeps form's state and validation results
17
17
* Supports any kind of validation functions
18
-
* Dirty checking (tracks both user interactions and value changes from initial state)
19
-
* Track changes from initial values with `isDirty`
18
+
* Dirty checking (tracks value changes from initial state)
20
19
* Separates data from view
21
20
* Relies on hooks, but can easily be used with class components
22
21
@@ -88,7 +87,7 @@ Hook that keeps on form field's data.
88
87
89
88
| Type <divstyle="width: 200px"></div> | Description |
90
89
|---- | ----------- |
91
-
| _{<br> value: any,<br> error: boolean<br> dirty: boolean,<br> isDirty: boolean,<br> onChange: (any, config?) => void<br> onBlur: (event, config?) => void<br> setValue: (value: any) => void<br> validate: (any, config?) => boolean or Promise<boolean><br> reset: () => void,<br> props: {<br> value: any,<br> onChange: (any, config?) => void<br> onBlur: (event, config?) => void<br> }<br>}_ | Object with field's data and callbacks.<br><br><ul><li>`value` - field's current value</li><li>`error` - is error present flag (`true` if value was validated and didn't pass validation, `false` otherwise)</li><li>`dirty` - indicates whether value of field was changed by user (used internally for validation timing)</li><li>`isDirty` - indicates whether current value differs from initial value (useful for enabling Save buttons)</li><li>`onChange` - callback for change event (changes the value and validates it if previous value wasn't correct)</li><li>`onBlur` - callback for blur event (validates the value)</li><li>`setValue` - function for setting the internal value (does not validate the input, enabling support for async data loading; also updates the initial value so `isDirty` remains `false`)</li><li>`validate` - function for validating field's value</li><li>`reset` - function for resetting field's data</li><li>`props` - set of props that can be spread on standard input elements (same as props in root object, just grouped for better DX)</li></ul><br/>`onChange`, `onBlur` and `validate` functions accept config as last parameter - this will override config from `useValidation` if provided. |
90
+
| _{<br> value: any,<br> error: boolean<br> dirty: boolean,<br> onChange: (any, config?) => void<br> onBlur: (event, config?) => void<br> setValue: (value: any) => void<br> validate: (any, config?) => boolean or Promise<boolean><br> reset: () => void,<br> props: {<br> value: any,<br> onChange: (any, config?) => void<br> onBlur: (event, config?) => void<br> }<br>}_ | Object with field's data and callbacks.<br><br><ul><li>`value` - field's current value</li><li>`error` - is error present flag (`true` if value was validated and didn't pass validation, `false` otherwise)</li><li>`dirty` - indicates whether current value differs from initial value (useful for enabling Save buttons and tracking changes)</li><li>`onChange` - callback for change event (changes the value and validates it if previous value wasn't correct)</li><li>`onBlur` - callback for blur event (validates the value)</li><li>`setValue` - function for setting the internal value (does not validate the input, enabling support for async data loading; also updates the initial value so `dirty` remains `false`)</li><li>`validate` - function for validating field's value</li><li>`reset` - function for resetting field's data</li><li>`props` - set of props that can be spread on standard input elements (same as props in root object, just grouped for better DX)</li></ul><br/>`onChange`, `onBlur` and `validate` functions accept config as last parameter - this will override config from `useValidation` if provided. |
92
91
93
92
#### Usage example
94
93
@@ -272,7 +271,7 @@ Util function for checking if any field in a form has been changed from its init
272
271
273
272
| Name | Type <divstyle="width: 200px"></div> | Required | Description |
274
273
| ---- | ---- | ---- | ----------- |
275
-
| fields |_{<br/> key: { isDirty: boolean },<br/> ...<br/>}_| yes | Form field's data (each field must have `isDirty` property - other properties are not important) |
274
+
| fields |_{<br/> key: { dirty: boolean },<br/> ...<br/>}_| yes | Form field's data (each field must have `dirty` property - other properties are not important) |
0 commit comments