question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom widget with HOC fails with < Error: Unsupported widget definition: object >

See original GitHub issue

Prerequisites

Description

I have a custom widget that is wrapped in the react-redux “connect” HOC. Until recently it worked, but now fails with “Error: Unsupported widget definition: object”. I have tried reverting to old versions of rjsf, but to no avail.

Steps to Reproduce

  1. Create a custom widget
  2. Wrap in connect({})(CustomWidget) to observe the error

Version

Tried various versions:

  • 2.0.0.alpha.1
  • 1.8.1
  • 1.4.0
  • 1.2.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
nuclearspikecommented, Jun 6, 2020

The same thing happened to me. The recent change was that you upgraded your react-redux package and they are using new react features that rjsf does not support yet. My temporary hack to make it work without reverting back to a lower version of react-redux was to wrap the connect call.

So, I wrote this:

const safeWrap = (Comp) => (props) => <Comp {...props} />

Then you just do this:

const ConnectedWidget = safeWrap(connect(mapStateToProps)(CustomWidget))

That works as a temp fix.

3reactions
snirpcommented, May 6, 2020

Perhaps a bit clearer:

import React from 'react'
import { connect } from 'react-redux'

const CustomWidget = ({ value, onChange, reduxProp, disabled }) => (
  // whatever
)

const mapStateToProps = (state, ownProps) => ({
  // reduxProp: ...
})

const ConnectedWidget = connect(mapStateToProps)(CustomWidget)

// Needs a wrapper due to this issue
// https://github.com/rjsf-team/react-jsonschema-form/issues/1736
const WrappedConnectedWidget = props => <ConnectedWidget {...props}/>

export default WrappedConnectedWidget
Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Widgets and Fields - React Jsonschema form
Custom Widgets and Fields¶. The API allows to specify your own custom widget and field components: A widget represents a HTML tag for...
Read more >
Custom Widgets for Android - HCL Volt MX Documentation
You can import and create your own custom widgets for the Android platform. Volt MX Irisplatform has defined a contract that any custom...
Read more >
Metric Chart Widget - VMware Docs
The widget displays data based on the metrics that you select. ... You can create ad-hoc reports when analyzing metrics.
Read more >
Unsupported Salesforce Objects and Fields in CRM Analytics
If you include an unsupported or inaccessible object in the sfdcDigest transformation, the dataflow fails at run time with an error message.
Read more >
Problem - Rocket Software Documentation
TMON Change Manager for CICS TS System Definition Auditor ... More Properties (Widget Properties) ... Customize WRD Error Messages.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found