@@ -32,10 +32,12 @@ interface Props extends FormProps {
32
32
*/
33
33
export default class SchemaForm extends Component < Props , { ui : UI | null } > {
34
34
optionsCache : Record < string , any [ ] >
35
+ optionsPromise : Record < string , boolean >
35
36
36
37
constructor ( props ) {
37
38
super ( props )
38
-
39
+ this . optionsCache = { }
40
+ this . optionsPromise = { }
39
41
this . state = {
40
42
ui : this . createUI ( props . schema ) ,
41
43
}
@@ -54,10 +56,11 @@ export default class SchemaForm extends Component<Props, { ui: UI | null }> {
54
56
console . log ( 'Deleting SchemaForm' )
55
57
}
56
58
57
- createUI ( schema : Schema ) {
59
+ createUI ( schema : Schema , optionsProcessed : boolean = false ) {
58
60
return createRenderFactory ( schema , {
59
61
resolveComponent : this . componentProvider ,
60
62
resolveOptions : this . optionsProvider ,
63
+ optionsProcessed,
61
64
} )
62
65
}
63
66
@@ -76,14 +79,15 @@ export default class SchemaForm extends Component<Props, { ui: UI | null }> {
76
79
if ( Array . isArray ( result ) ) return result
77
80
if ( result === null ) return
78
81
if ( result . then ) {
79
- result . then ( ( result ) => {
80
- if ( this . optionsCache [ format ] !== result ) {
82
+ if ( ! this . optionsPromise [ format ] ) {
83
+ result . then ( ( result ) => {
84
+ this . optionsPromise [ format ] = true
81
85
this . optionsCache [ format ] = result
82
- console . log ( 'Option loaded.' )
83
- this . forceUpdate ( ) // Options Loaded.
84
- }
85
- } )
86
-
86
+ this . setState ( {
87
+ ui : this . createUI ( this . props . schema , true ) ,
88
+ } )
89
+ } )
90
+ }
87
91
return this . optionsCache [ format ] || [ ]
88
92
}
89
93
}
0 commit comments