Prefered way to update schemas dynamically outside of JsonForms component

Hey :smile:
What is the preferred way to update jsonSchema and uiSchema dynamically outside of JsonForms component?
At the moment I’m storing jsonSchema&uiSchema values in a React.useState and I modify them via the setter function.
It works, although:

  1. Am I not reinventing the wheel here? :sweat_smile: Is there any preferred built-in way to do that via JsonForms libs?
  2. I’m a bit concerned about performance in my approach, as modifying schemas triggers JsonForms parent rerender. Seems like this might ruin any optimizations provided by JsonForms lib

Hi @pegu,

Storing and modifying the schema and uiSchema outside of JSON Forms is completely fine. Whenever you update them, all elements which have a new object identity will rerender.

This depends a bit in your use case. What is the reason that you modify the schema and uiSchema on the fly and how often does it happen?

Hey @sdirix

Im doing something similar to JSON Forms Editor (jsonforms-editor.netlify.app)
So, I need to dynamically modify schema to add form fields and modify uiSchema to modify (is required, labels, styles, etc.) them on the fly.
So there might be quite a few of inputs.

Hi @pegu,

I think that’s fine then. If you make sure that the schema and uischema are not full deep copies then you can save a bit on performance. But it’s sufficient to worry about that once you actually run into performance issues.

Great, thanks for your time @sdirix :smile:
Have a wonderful day and keep up the good work :smile: