We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dd5ce2a commit 16905bdCopy full SHA for 16905bd
src/forms/helpers/useFormControl.js
@@ -9,7 +9,7 @@ export function useFormControl(name, type) {
9
}
10
11
return {
12
- getValue: () => encode(formState.getValue(name) || getEmptyValue(type), type),
+ getValue: () => encode(formState.getValue(name), type),
13
setValue,
14
handleOnChange: ({ target }) => {
15
const value = getTargetValue(target);
@@ -39,6 +39,10 @@ function getEmptyValue(type) {
39
40
41
function encode(value, type) {
42
+ if (typeof value === 'undefined') {
43
+ return getEmptyValue(type);
44
+ }
45
+
46
if (type === 'datetime-local') {
47
return value && value.toISOString().slice(0, 16);
48
0 commit comments