react-jsonschema-form
react-jsonschema-form copied to clipboard
Using SchemaField when upgrading from v4 to v5
Prerequisites
- [X] I have read the documentation
What theme are you using?
core
What is your question?
Hi! I am trying to upgrade from v4 to v5, but my code creates a customSchemaField in order to make adjustments to the uiSchema for the properties based on type, description or other information. I realize this is not an ideal solution, but because of this I am not able to upgrade my code since I need to be able to render SchemaField. I have read the documentation and this post https://github.com/rjsf-team/react-jsonschema-form/issues/4062, reading that it is not ideal to change schemafield, but is it possible to still render Schemafield? When I import it from import SchemaField from "@rjsf/core/src/components/fields/SchemaField"; v5, I get error with loaders not configures for the node_modules (@rjsf/core/src/components/fields/SchemaField). Thank you for all help or ideas to try and solve this.
Here is an simplification of of how my CustomSchemaField is build up:
const SetDefaultTypes = props => {
if (props.schema.format === "upload") {
props.uiSchema["ui:widget"] =
props.uiSchema["ui:widget"] || JSON_SCHEMA.WIDGETS.CUSTOM_UPLOAD_WIDGET;
}
.... etc
};
const SetDescription =props=> {
const description =
props.uiSchema["ui:description"] || props.schema.description;
if (description) {
props.uiSchema["ui:description"] = <FormatTextMarkup text={description} />;
}
};
...etc
export const CustomSchemaField = props => {
if (props.idSchema.$id === "root") {
return <SchemaField {...props} />;
}
SetDefaultTypes(newProps);
SetDescription(newProps);
... etc
return <SchemaField {...newProps} />;
};
Rather than trying to import it from core
you can obtain it from the registry
using the following code:
import { getDefaultRegistry } from `@rjsf/core`
const { fields: { SchemaField } } = getDefaultRegistry();
Thank you, it worked!
@hannatorj Awesome, I will close this issue then