react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

getWidget throws "Unsupported widget definition: undefined" when widget param is a string

Open skysantoroa opened this issue 2 years ago • 5 comments

Prerequisites

What theme are you using?

core

Version

4.1.1

Current Behavior

Create a custom widget like

DateWidget: (props: WidgetProps) => {
    const { value, label, onChange, required, readonly, disabled, options, schema } =
      props
    const widget = utils.getWidget(schema, 'date')
    return (
      <>{widget}</>
    )
  },

Even though the widget parameter passed to the getWidget function is a string, it will fail throwing "Unsupported widget definition: undefined".

Expected Behavior

Getting the proper Widget given the schema and its key

Steps To Reproduce

Read current behaviour

Environment

- OS: Ubuntu 22
- Node: 16
- npm: 8

Anything else?

No response

skysantoroa avatar Jul 05 '22 11:07 skysantoroa

Have you added the new widget to the widgets prop of the Form?

heath-freenome avatar Jul 05 '22 17:07 heath-freenome

There is no new widget, I'm just trying to get the default DateWidget here

skysantoroa avatar Jul 06 '22 07:07 skysantoroa

Which theme?

heath-freenome avatar Jul 08 '22 20:07 heath-freenome

Bootstrap 3 (default)

skysantoroa avatar Jul 11 '22 06:07 skysantoroa

using const widget = utils.getWidget(schema, 'date') will cause this problem if the utils.getSchemaType(schema) returns something other than string

heath-freenome avatar Aug 22 '22 21:08 heath-freenome

This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

stale[bot] avatar Mar 09 '24 17:03 stale[bot]

This issue was closed because of lack of recent activity. Reopen if you still need assistance.

stale[bot] avatar Apr 10 '24 01:04 stale[bot]