Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SchemaField when upgrading from v4 to v5 #4190

Open
1 task done
hannatorj opened this issue May 10, 2024 · 1 comment
Open
1 task done

Using SchemaField when upgrading from v4 to v5 #4190

hannatorj opened this issue May 10, 2024 · 1 comment

Comments

@hannatorj
Copy link

Prerequisites

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 #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} />;
};

@hannatorj hannatorj added needs triage Initial label given, to be assigned correct labels and assigned question labels May 10, 2024
@heath-freenome
Copy link
Member

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();

@heath-freenome heath-freenome added awaiting response and removed needs triage Initial label given, to be assigned correct labels and assigned labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants