You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a memoized component (React.memo(Component)) as custom widget raise the following error:
utils.js:210 Uncaught Error: Unsupported widget definition: object
at getWidget (utils.js:210)
at getWidget (utils.js:224)
at BooleanField (BooleanField.js:52)
I investigated the source code I saw that into the utils.js file there is an if statement that fails to recognize the memoized component:
// utils.js, line 201-203. ReactIs.isMemo(widget) gives false as result
if (typeof widget === "function" || ReactIs.isForwardRef(_react["default"].createElement(widget)) || ReactIs.isMemo(widget)) {
return mergeOptions(widget);
}
Googling around I found out that into the ReactIs library the behavior of the isMemo method was recently changed: #PR 17278
I'm wondering if also the react-jsonschema-form library has to change how it checks that conditions. Removing the React.memo that wrap my component makes the "Unsupported widget definition" error disappear.
In my code I'm trying to use a custom CheckboxWidget.
Steps to Reproduce
Create a memoized component e.g. const MemoizedComponent = React.memo(/* could be also a silly div*/)
Use that component as custom widget e.g. { CheckboxWidget: MemoizedComponent }
Render the form
Expected behavior
A memoized component shouldn't breaks the page
Actual behavior
Use e memoized component as custom widget breaks the page
This issue has been automatically marked as stale 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.
Prerequisites
Description
Using a memoized component (React.memo(Component)) as custom widget raise the following error:
I investigated the source code I saw that into the utils.js file there is an if statement that fails to recognize the memoized component:
Googling around I found out that into the ReactIs library the behavior of the isMemo method was recently changed: #PR 17278
I'm wondering if also the react-jsonschema-form library has to change how it checks that conditions. Removing the React.memo that wrap my component makes the "Unsupported widget definition" error disappear.
In my code I'm trying to use a custom CheckboxWidget.
Steps to Reproduce
Expected behavior
A memoized component shouldn't breaks the page
Actual behavior
Use e memoized component as custom widget breaks the page
Version
react: "16.13.1"
react-jsonschema-form: "2.0.0-alpha.1"
The text was updated successfully, but these errors were encountered: