File tree 3 files changed +7
-1
lines changed
3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export function FormExamples() {
21
21
switchField2 : true ,
22
22
checkboxField2 : true ,
23
23
radioField2 : 'b' ,
24
+ numberField : null ,
24
25
dateField : new Date ( ) . toISOString ( ) ,
25
26
} }
26
27
onChange = { console . info }
Original file line number Diff line number Diff line change 1
1
import { useContext } from 'react' ;
2
2
import { FormContext } from './form-helpers' ;
3
3
import { toDatetimeLocal , fromDatetimeLocal } from '../../utils/formatters' ;
4
+ import { isNull } from '../../utils/types' ;
4
5
5
6
export function useFormControl ( name , type ) {
6
7
const formState = useContext ( FormContext ) ;
@@ -40,7 +41,7 @@ function getEmptyValue(type) {
40
41
}
41
42
42
43
function encode ( value , type ) {
43
- if ( typeof value === 'undefined' ) {
44
+ if ( typeof value === 'undefined' || isNull ( value ) ) {
44
45
return getEmptyValue ( type ) ;
45
46
}
46
47
Original file line number Diff line number Diff line change @@ -17,3 +17,7 @@ export function isString(value) {
17
17
export function isDate ( value ) {
18
18
return Object . prototype . toString . call ( value ) === '[object Date]' ;
19
19
}
20
+
21
+ export function isNull ( value ) {
22
+ return value === null ;
23
+ }
You can’t perform that action at this time.
0 commit comments