# JsonForms Controlled/Uncontrolled

**URL:** <https://jsonforms.discourse.group/t/jsonforms-controlled-uncontrolled/2496>\
**Category:** General\
**Created:** [December 6, 2024, 10:25pm UTC](https://jsonforms.discourse.group/t/jsonforms-controlled-uncontrolled/2496 "2024-12-06T22:25:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cihad](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/cihad/32/1166_2.png) [@cihad](https://jsonforms.discourse.group/u/cihad)\
**Post date:** [December 6, 2024, 10:25pm UTC](https://jsonforms.discourse.group/t/jsonforms-controlled-uncontrolled/2496/1 "2024-12-06T22:25:41Z")

</div>

I think the `JsonForms` React component does not follow the best practice of controlled/uncontrolled pattern.

Controlled JsonForms should get `data` and `onChange` props, (`value` instead of `data` would be a better choice.)

Uncontrolled JsonForms should get `defaultData` (or more commonly: `defaultValue`),

Currently the JsonForms component works as a controlled/uncontrolled mix, which can cause confusion.

---

<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:** [December 9, 2024, 9:47am UTC](https://jsonforms.discourse.group/t/jsonforms-controlled-uncontrolled/2496/2 "2024-12-09T09:47:32Z")

</div>

Hi @cihad,

Yes, you are right. The current JSON Forms component is kind of a mix and therefore hard to use in some scenarios. However we definitely need a major version release to change it as otherwise a lot of consumer will break.

However, there is a way around this. Using JSON Forms middleware, you can use the `JSONForms` component in a completely controlled style, so I would recommend using that if you need full control. See [here](https://jsonforms.io/docs/middleware#using-json-forms-in-controlled-style) for the docs.

---

<div class="post-metadata">

**Author:** ![cihad](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/cihad/32/1166_2.png) [@cihad](https://jsonforms.discourse.group/u/cihad)\
**Post date:** [December 9, 2024, 4:46pm UTC](https://jsonforms.discourse.group/t/jsonforms-controlled-uncontrolled/2496/3 "2024-12-09T16:46:57Z")

</div>

Additionally `JsonForms` is plural. Of course, there is a parallelism with the library name here. But single `JsonForm` seems to be better. After all, this component does not control more than one form. It can be taken into consideration in future versions.
