File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -135,11 +135,15 @@ export class FormStore {
135
135
} ;
136
136
137
137
private warningUnhooked = ( ) => {
138
- if ( process . env . NODE_ENV !== 'production' && ! this . formHooked ) {
139
- warning (
140
- false ,
141
- 'Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?' ,
142
- ) ;
138
+ if ( process . env . NODE_ENV !== 'production' ) {
139
+ setTimeout ( ( ) => {
140
+ if ( ! this . formHooked ) {
141
+ warning (
142
+ false ,
143
+ 'Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?' ,
144
+ ) ;
145
+ }
146
+ } ) ;
143
147
}
144
148
} ;
145
149
Original file line number Diff line number Diff line change @@ -517,6 +517,7 @@ describe('Form.Basic', () => {
517
517
} ) ;
518
518
519
519
it ( 'warning if call function before set prop' , ( ) => {
520
+ jest . useFakeTimers ( ) ;
520
521
resetWarned ( ) ;
521
522
const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
522
523
@@ -529,10 +530,12 @@ describe('Form.Basic', () => {
529
530
530
531
mount ( < Test /> ) ;
531
532
533
+ jest . runAllTimers ( ) ;
532
534
expect ( errorSpy ) . toHaveBeenCalledWith (
533
535
'Warning: Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?' ,
534
536
) ;
535
537
errorSpy . mockRestore ( ) ;
538
+ jest . useRealTimers ( ) ;
536
539
} ) ;
537
540
538
541
it ( 'filtering fields by meta' , async ( ) => {
You can’t perform that action at this time.
0 commit comments