rjsf-team / react-jsonschema-form

A React component for building Web forms from JSON Schema.
https://rjsf-team.github.io/react-jsonschema-form/
Apache License 2.0
14.3k stars 2.19k forks source link

useMuiComponent from example fails #2905

Closed joseika closed 2 years ago

joseika commented 2 years ago

Prerequisites

What theme are you using?

material-ui

Version

4.2.0

Current Behavior

I implemented a custom field based on the documentation example: https://react-jsonschema-form.readthedocs.io/en/latest/advanced-customization/material-ui/customizing-material-ui/#example-of-a-custom-field-for-rjsfmaterial-ui

Error: export 'useMuiComponent' (imported as 'useMuiComponent') was not found in '@rjsf/material-ui/v4' (possible exports: ArrayFieldTemplate, FieldTemplate, Fields, MuiComponentContext, MuiForm, ObjectFieldTemplate, Theme, Widgets, default)

Is the export missing, or is the documentation outdated?

Expected Behavior

Examples in documentation should work.

Steps To Reproduce

  1. Set up a Create React App project
  2. Install @rjsf/core@4.2.0, rjsf/material-ui@4.2.0
  3. Add code from example
  4. Build fails

Environment

- OS: Ubuntu 20.04
- Node: 16.14.0
- npm: 8.3.1

Anything else?

No response

heath-freenome commented 2 years ago

Whoops, the export is missing. You can also do React.useContext(MuiComponentContext) as a work around

heath-freenome commented 2 years ago

Fixed in v5 beta by removing the whole hooks implementation: https://react-jsonschema-form.readthedocs.io/en/latest/5.x%20upgrade%20guide/