github rjsf-team/react-jsonschema-form v0.35.0

latest releases: 5.18.4, v5.18.4, 5.18.3...
7 years ago

Changelog

Breaking changes

The options prop passed to your custom widget can now be used for any purpose, and not only the list of options (label and value) for enum fields. This latter list of options is now passed in an enumOptions property in the options prop.

That means that if you have code like this:

const schema = {
  type: "string",
  enum: ["foo", "bar"],
};

function MyCustomWidget(props) {
  const {options}  props; // Previously, the list of enum options was passed straight away
  return (
    <select>{
      options.map(({label, value}, i) => {
        return <option key={i} value={value}>{label}</option>;
      })
    }</select>
  );
}

const uiSchema = {
  "ui:widget": MyCustomWidget
};

You need to upgrade it to:

const schema = {
  type: "string",
  enum: ["foo", "bar"],
};

function MyCustomWidget(props) {
  const {options}  props;
  const {enumOptions} = options; // The list of options is now one level deeper
  return (
    <select>{
      enumOptions.map(({label, value}, i) => { 
        return <option key={i} value={value}>{label}</option>;
      })
    }</select>
  );
}

const uiSchema = {
  "ui:widget": MyCustomWidget
};

Don't miss a new react-jsonschema-form release

NewReleases is sending notifications on new releases.