A custom ObjectFieldTemplate calls registry.schemaUtils.canExpand
Detect
- Your custom
ObjectFieldTemplateimportscanExpandfrom@rjsf/utilsto decide whether to show its Add button. - The type checker reports
Module '"@rjsf/utils"' has no exported member 'canExpand'.
Change
Whether an object naming no additionalProperties takes extra keys is now a form setting, additionalPropertiesWhenAbsent, which travels in the SchemaContext (#2137). Every theme's ObjectFieldTemplate now calls registry.schemaUtils.canExpand(), which passes the form's own SchemaContext, and @rjsf/utils no longer exports canExpand() itself (see @rjsf/utils no longer exports utilities no other RJSF package uses).
Do the same in your template:
-import { canExpand } from '@rjsf/utils';
-{canExpand(schema, uiSchema, formData) && <AddButton onClick={onAddProperty} />}
+{registry.schemaUtils.canExpand(schema, uiSchema, formData) && <AddButton onClick={onAddProperty} />}
Verify
- Your template compiles and shows the Add button on the same objects the built-in themes do.
- If you implement
SchemaUtilsTypeyourself, it needs the new methods; see SchemaUtilsType gains canExpand and allowsAdditionalProperties.
Also read: