react-json-schema-form-extras icon indicating copy to clipboard operation
react-json-schema-form-extras copied to clipboard

Invalid Type

Open lovato opened this issue 5 years ago • 0 comments

Hi. I am using react-jsonschema-form in UMD format. Therefore, trying to use your extension the same way to get typeahead functionality.

a) Package.json

  "react-jsonschema-form": "^1.5.0",
  "react-jsonschema-form-extras": "^0.9.40",

b) Load dependencies

  <script src="/npm/js/react-jsonschema-form.js"></script>
  <!-- <script src="/npm/js/form-with-extras.js"></script> -->

c) My Form Instance

  const JSONForm = window.JSONSchemaForm.default;

At this point, everything works fine. Perfectly nice should I say.

But when I load form-with-extras.js, it is not clear to me if I need to install all peer dependencies or not. I think I don't need them since I am using your /dist folder, which I guess contains everything. However, Typeahead library (from official repo) has a CSS file, which is not included in yours. So, perhaps it needs to be installed as well. It is unclear to me. The same way, I am not clear if I install react-bootstrap-typeahead I should load it explicitly the way I load all my other dependencies.

If I ignore that and try to use it anyways, I have no idea how to get an instance of those. It is explained that it uses the internal JSONSchemaForm extension mechanism. Well, since I was not able to figure that out, I tried to use anyways. At least load it...

Scenarios at JS console (chrome)

a) Not loading dist/form-with-extras.js

image

b) Loading dist/form-with-extras.js

image

It sorts of change my const JSONForm (because it actually interferes on window.JSONSchemaForm.default), and due to that, no one of my <JSONForm/>s is working anymore, with the error:

image

I tried several combinations, but since neither react-jsonschema-form nor react-jsonschema-form-extras provide UMD documentation, I am stuck at this point. I am not sure if I am using it incorrectly, or there is an issue here.

Please, can someone provide me some guidance here?

lovato avatar Apr 21 '19 19:04 lovato