# Prefered way to update schemas dynamically outside of JsonForms component

**URL:** <https://jsonforms.discourse.group/t/prefered-way-to-update-schemas-dynamically-outside-of-jsonforms-component/2121>\
**Category:** General\
**Created:** [May 7, 2024, 9:50am UTC](https://jsonforms.discourse.group/t/prefered-way-to-update-schemas-dynamically-outside-of-jsonforms-component/2121 "2024-05-07T09:50:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pegu](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pegu](https://jsonforms.discourse.group/u/pegu)\
**Post date:** [May 7, 2024, 9:50am UTC](https://jsonforms.discourse.group/t/prefered-way-to-update-schemas-dynamically-outside-of-jsonforms-component/2121/1 "2024-05-07T09:50:45Z")

</div>

Hey 😄  
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? 😅 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

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [May 7, 2024, 3:56pm UTC](https://jsonforms.discourse.group/t/prefered-way-to-update-schemas-dynamically-outside-of-jsonforms-component/2121/2 "2024-05-07T15:56:33Z")

</div>

Hi @pegu,

> [@pegu](#):
>
> Am I not reinventing the wheel here? 😅 Is there any preferred built-in way to do that via JsonForms libs?

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.

> [@pegu](#):
>
> 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

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?

---

<div class="post-metadata">

**Author:** ![pegu](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pegu](https://jsonforms.discourse.group/u/pegu)\
**Post date:** [May 8, 2024, 7:18am UTC](https://jsonforms.discourse.group/t/prefered-way-to-update-schemas-dynamically-outside-of-jsonforms-component/2121/3 "2024-05-08T07:18:20Z")

</div>

Hey @sdirix

Im doing something similar to [JSON Forms Editor (jsonforms-editor.netlify.app)](https://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.

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [May 8, 2024, 7:20am UTC](https://jsonforms.discourse.group/t/prefered-way-to-update-schemas-dynamically-outside-of-jsonforms-component/2121/4 "2024-05-08T07:20:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pegu](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pegu](https://jsonforms.discourse.group/u/pegu)\
**Post date:** [May 8, 2024, 8:40am UTC](https://jsonforms.discourse.group/t/prefered-way-to-update-schemas-dynamically-outside-of-jsonforms-component/2121/5 "2024-05-08T08:40:46Z")

</div>

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