@@ -280,13 +280,14 @@ describe("useField", () => {
280
280
const { input } = useField ( name , {
281
281
subscription : { value : true } ,
282
282
formatOnBlur,
283
+ defaultValue : "" ,
283
284
} ) ;
284
285
const { onChange, onFocus, onBlur } = input ;
285
286
spy ( onChange , onFocus , onBlur ) ;
286
- return < input { ...input } /> ;
287
+ return < input { ...input } value = { input . value || "" } /> ;
287
288
} ;
288
289
const { rerender } = render (
289
- < Form onSubmit = { onSubmitMock } >
290
+ < Form onSubmit = { onSubmitMock } initialValues = { { myField : "" , dog : "" } } >
290
291
{ ( ) => (
291
292
< form >
292
293
< MyField name = "myField" />
@@ -301,7 +302,7 @@ describe("useField", () => {
301
302
expect ( spy . mock . calls [ 1 ] [ 2 ] ) . toBe ( spy . mock . calls [ 0 ] [ 2 ] ) ; // onBlur
302
303
303
304
rerender (
304
- < Form onSubmit = { onSubmitMock } >
305
+ < Form onSubmit = { onSubmitMock } initialValues = { { myField : "" , dog : "" } } >
305
306
{ ( ) => (
306
307
< form >
307
308
< MyField name = "dog" formatOnBlur />
@@ -325,13 +326,14 @@ describe("useField", () => {
325
326
const { input } = useField ( name , {
326
327
subscription : { value : true } ,
327
328
parse,
329
+ defaultValue : "" ,
328
330
} ) ;
329
331
const { onChange, onFocus, onBlur } = input ;
330
332
spy ( onChange , onFocus , onBlur ) ;
331
- return < input { ...input } /> ;
333
+ return < input { ...input } value = { input . value || "" } /> ;
332
334
} ;
333
335
const { rerender } = render (
334
- < Form onSubmit = { onSubmitMock } >
336
+ < Form onSubmit = { onSubmitMock } initialValues = { { myField : "" , dog : "" } } >
335
337
{ ( ) => (
336
338
< form >
337
339
< MyField name = "myField" />
@@ -346,7 +348,7 @@ describe("useField", () => {
346
348
expect ( spy . mock . calls [ 1 ] [ 2 ] ) . toBe ( spy . mock . calls [ 0 ] [ 2 ] ) ; // onBlur
347
349
348
350
rerender (
349
- < Form onSubmit = { onSubmitMock } >
351
+ < Form onSubmit = { onSubmitMock } initialValues = { { myField : "" , dog : "" } } >
350
352
{ ( ) => (
351
353
< form >
352
354
< MyField name = "dog" parse = { ( x ) => x } />
@@ -370,13 +372,14 @@ describe("useField", () => {
370
372
const { input } = useField ( name , {
371
373
subscription : { value : true } ,
372
374
format,
375
+ defaultValue : "" ,
373
376
} ) ;
374
377
const { onChange, onFocus, onBlur } = input ;
375
378
spy ( onChange , onFocus , onBlur ) ;
376
- return < input { ...input } /> ;
379
+ return < input { ...input } value = { input . value || "" } /> ;
377
380
} ;
378
381
const { rerender } = render (
379
- < Form onSubmit = { onSubmitMock } >
382
+ < Form onSubmit = { onSubmitMock } initialValues = { { myField : "" , dog : "" } } >
380
383
{ ( ) => (
381
384
< form >
382
385
< MyField name = "myField" />
@@ -391,7 +394,7 @@ describe("useField", () => {
391
394
expect ( spy . mock . calls [ 1 ] [ 2 ] ) . toBe ( spy . mock . calls [ 0 ] [ 2 ] ) ; // onBlur
392
395
393
396
rerender (
394
- < Form onSubmit = { onSubmitMock } >
397
+ < Form onSubmit = { onSubmitMock } initialValues = { { myField : "" , dog : "" } } >
395
398
{ ( ) => (
396
399
< form >
397
400
< MyField name = "dog" format = { ( x ) => x } />
@@ -415,13 +418,14 @@ describe("useField", () => {
415
418
const { input } = useField ( name , {
416
419
subscription : { value : true } ,
417
420
component,
421
+ defaultValue : "" ,
418
422
} ) ;
419
423
const { onChange, onFocus, onBlur } = input ;
420
424
spy ( onChange , onFocus , onBlur ) ;
421
- return < input { ...input } /> ;
425
+ return < input { ...input } value = { input . value || "" } /> ;
422
426
} ;
423
427
const { rerender } = render (
424
- < Form onSubmit = { onSubmitMock } >
428
+ < Form onSubmit = { onSubmitMock } initialValues = { { myField : "" , dog : "" } } >
425
429
{ ( ) => (
426
430
< form >
427
431
< MyField name = "myField" />
@@ -436,7 +440,7 @@ describe("useField", () => {
436
440
expect ( spy . mock . calls [ 1 ] [ 2 ] ) . toBe ( spy . mock . calls [ 0 ] [ 2 ] ) ; // onBlur
437
441
438
442
rerender (
439
- < Form onSubmit = { onSubmitMock } >
443
+ < Form onSubmit = { onSubmitMock } initialValues = { { myField : "" , dog : "" } } >
440
444
{ ( ) => (
441
445
< form >
442
446
< MyField name = "dog" component = "select" />
0 commit comments