Custom renderers not updating when form data change

I develop custom renderers in react , and with the help of useState hook I change my formData variable which is pass in JSONFORM. My formdata change with this method but UI input filed not update their value and they show previous value of formdata, but if I use Json forms default renderers then they re render and update according to new form data. Can you please tell me why my custom renderers not behaving like default renderers in this case?
i pass my variable in my jsonform
<JsonForms
data={formdata2}
schema={schema}
uischema={UiSchema}
renderers={renders}
cells={materialCells}
onChange={({ data, errors }) => changeHandler(data, errors)}
additionalErrors={additionalErrors}
validationMode={config}
/>
I also see in ctx provide by jsonform, ctx also update but my custom renderers show previous value of formdata.

@SatendraRaghav,

If I understand correctly then you maintain your data in an own setState within your custom renderer. This is not necessary. By default you should always just render the data handed over via the props and dispatch any changes to this data via the also handed over handleChange.

Maintaining an own setState within your custom renderer will require additional syncing whenever the data coming in by JSON Forms changes. This is only required for advanced use cases.

In my custom renderer, I am using just render the data handed over via the props, but I want to change my whole formdata which is pass in data props of JsonForms component with setState, but whenever i change it , changes are not reflect in custom renderer.
Mu Custom Component render again but value giving by props is not changing.

Hi @sdirix,
Is my case whole formdata is change but value of custom renderer is not reset, it still show previous value of formdata .

Thank you @sdirix for reply,
But i am not using setState in my custom renderer, i am changing formdata variable which is passed in JsonForms directly.
Example:
<JsonForms
data={formdata}
schema={schema}
uischema={UiSchema}
renderers={renders}
cells={materialCells}
onChange={({ data, errors }) => changeHandler(data, errors)}
additionalErrors={additionalErrors}
validationMode={config}
/>
When i pass my update data to jsonform in data props , it will not update my custom renderer.
my custom renderers have no any other state , it is same as mention in documatation.

Hi @SatendraRaghav,

Are you making sure that your data object is updated correctly? If your custom renderer handles an object and only a property within the object changes but not the object itself, then by default our memo will kick in and your renderer will not rerender, even if it accesses the internal data.

Can you post your code or a minimal example so we can reproduce this on our side?

1 Like

@sdirix Thank you for your response, I find error on my custom renderers.It is solve now.