JsonForms Controlled/Uncontrolled

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.

1 Like

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 for the docs.

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.