Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including the JS in our own bundle? #134

Open
sergei-maertens opened this issue Jan 4, 2024 · 2 comments
Open

Including the JS in our own bundle? #134

sergei-maertens opened this issue Jan 4, 2024 · 2 comments

Comments

@sergei-maertens
Copy link

I see that the form field declares the media property which loads your react, react-dom and react-modal dependencies + the actual UI code.

We happen to already use react & react-modal in our (admin) application, so it would be cool if we could avoid loading those dependencies multiple times.

Do you have any pointers or documentation on how we could include your UI code in our own bundle? We use webpack for bundling. I can see that https://github.com/bhch/react-json-form is published to npm, but it only lists React v17 in the peer dependencies. Are there known issues with React 18?

@bhch
Copy link
Owner

bhch commented Jan 5, 2024

I'll test it out with React 18 and update the dependencies.


To avoid loading the dependencies, you can subclass the JSONFormWidget and override the media method to remove those js file references which you don't need.


If you are going to include the underlying js library in your bundle, then you'll be responsible for rendering the widget yourself on relevant pages. You can find the complete guide in react-json-form docs: https://bhch.github.io/react-json-form/docs/usage/node/.

@bhch
Copy link
Owner

bhch commented Jan 7, 2024

I've published a new version of react-json-form on npm which supports React 18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants