AnyOfField and OneOfField expect their options already retrieved
Detect
- In your custom field:
AnyOfFieldorOneOfFieldrendered with raw option schemas, such as<AnyOfField {...props} options={schema.anyOf} />.
Change
SchemaField retrieves each anyOf/oneOf option for the field's data and hands the retrieved schemas to AnyOfField/OneOfField as options. Retrieve them first. An option may be a boolean schema, which SchemaField retrieves as an empty one:
-return <AnyOfField {...props} options={schema.anyOf} />;
+const options = (schema.anyOf ?? []).map((option) =>
+ registry.schemaUtils.retrieveSchema(typeof option === 'object' ? option : {}, formData),
+);
+return <AnyOfField {...props} options={options} />;
A custom field that passes on the options prop it received from SchemaField is unaffected.
Verify
- The field lists resolved options and selects the one matching its data.
Also read: