File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ export default function useForm<TForm extends FormDataType>(
58
58
maybeData ?: TForm | ( ( ) => TForm ) ,
59
59
) : Writable < InertiaForm < TForm > > {
60
60
const rememberKey = typeof rememberKeyOrData === 'string' ? rememberKeyOrData : null
61
- const inputData = typeof rememberKeyOrData === 'string' ? maybeData : rememberKeyOrData
61
+ const inputData = ( typeof rememberKeyOrData === 'string' ? maybeData : rememberKeyOrData ) ?? { }
62
62
const data : TForm = typeof inputData === 'function' ? inputData ( ) : ( inputData as TForm )
63
63
const restored = rememberKey
64
64
? ( router . restore ( rememberKey ) as { data : TForm ; errors : Record < keyof TForm , string > } | null )
Original file line number Diff line number Diff line change @@ -44,11 +44,11 @@ export default function useForm<TForm extends FormDataType>(
44
44
maybeData ?: TForm | ( ( ) => TForm ) ,
45
45
) : InertiaForm < TForm > {
46
46
const rememberKey = typeof rememberKeyOrData === 'string' ? rememberKeyOrData : null
47
- const data = typeof rememberKeyOrData === 'string' ? maybeData : rememberKeyOrData
47
+ const data = ( typeof rememberKeyOrData === 'string' ? maybeData : rememberKeyOrData ) ?? { }
48
48
const restored = rememberKey
49
49
? ( router . restore ( rememberKey ) as { data : TForm ; errors : Record < keyof TForm , string > } )
50
50
: null
51
- let defaults = typeof data === 'object ' ? cloneDeep ( data ) : cloneDeep ( data ( ) )
51
+ let defaults = typeof data === 'function ' ? cloneDeep ( data ( ) ) : cloneDeep ( data )
52
52
let cancelToken = null
53
53
let recentlySuccessfulTimeoutId = null
54
54
let transform = ( data ) => data
@@ -91,7 +91,7 @@ export default function useForm<TForm extends FormDataType>(
91
91
return this
92
92
} ,
93
93
reset ( ...fields ) {
94
- const resolvedData = typeof data === 'object ' ? cloneDeep ( defaults ) : cloneDeep ( data ( ) )
94
+ const resolvedData = typeof data === 'function ' ? cloneDeep ( data ( ) ) : cloneDeep ( data )
95
95
const clonedData = cloneDeep ( resolvedData )
96
96
if ( fields . length === 0 ) {
97
97
defaults = clonedData
You can’t perform that action at this time.
0 commit comments