@@ -133,8 +133,14 @@ export default function PredefinedGallery({
133
133
mods ?: Mods ,
134
134
} ) : Node {
135
135
const classes = useStyles ( ) ;
136
- const schemaData = ( parse ( schema ) : { [ string ] : any } ) || { } ;
137
- const uiSchemaData = ( parse ( uischema ) : { [ string ] : any } ) || { } ;
136
+ const schemaData = React . useMemo (
137
+ ( ) => ( parse ( schema ) : { [ string ] : any } ) || { } ,
138
+ [ schema ] ,
139
+ ) ;
140
+ const uiSchemaData = React . useMemo (
141
+ ( ) => ( parse ( uischema ) : { [ string ] : any } ) || { } ,
142
+ [ uischema ] ,
143
+ ) ;
138
144
const allFormInputs = excludeKeys (
139
145
Object . assign (
140
146
{ } ,
@@ -180,23 +186,21 @@ export default function PredefinedGallery({
180
186
}
181
187
onChange ( stringify ( schemaData ) , stringify ( uiSchemaData ) ) ;
182
188
}
183
- } , [ uischema , schema ] ) ;
189
+ } , [ uiSchemaData , schemaData ] ) ;
184
190
return (
185
191
< div className = { classes . preDefinedGallery } >
186
192
< CardGallery
187
- definitionSchema = { schemaData . definitions }
188
- definitionUiSchema = { uiSchemaData . definitions }
193
+ definitionSchema = { schemaData . definitions || { } }
194
+ definitionUiSchema = { uiSchemaData . definitions || { } }
189
195
onChange = { (
190
196
newDefinitions : { [ string ] : any } ,
191
197
newDefinitionsUi : { [ string ] : any } ,
192
198
) => {
193
- schemaData . definitions = newDefinitions ;
194
- uiSchemaData . definitions = newDefinitionsUi ;
195
199
// propagate changes in ui definitions to all relavant parties in main schema
196
200
197
201
propagateDefinitionChanges (
198
- schemaData ,
199
- uiSchemaData ,
202
+ { ... schemaData , definitions : newDefinitions } ,
203
+ { ... uiSchemaData , definitions : newDefinitionsUi } ,
200
204
( newSchema , newUiSchema ) =>
201
205
onChange ( stringify ( newSchema ) , stringify ( newUiSchema ) ) ,
202
206
categoryHash ,
0 commit comments