Open zzph opened 1 month ago
Any ideas on this? I'm blocked from using this awesome library because of it
The widget has access to the formData
at its current level (in your example the widget will get the value for name
) via the value
prop. Is there a reason why you need access to all of the formData
within a single widget?
Thanks for the reply.
In this case, the field would “auto suggest” a value based on other fields (which can also be corrected by the user if not correct).
Is that clear? Is there a way to achieve it?
On Sat, 18 May 2024 at 5:38 am, Heath C @.***> wrote:
The widget has access to the formData at its current level (in your example the widget will get the value for name) via the value prop. Is there a reason why you need access to all of the formData within a single widget?
— Reply to this email directly, view it on GitHub https://github.com/rjsf-team/react-jsonschema-form/issues/4192#issuecomment-2118259344, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUBXB72LVJNDJYNTNXQCALLZCZMDNAVCNFSM6AAAAABHRPO5VGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJYGI2TSMZUGQ . You are receiving this because you authored the thread.Message ID: @.***>
@zzph I'm wondering if the "freezing" of the form you are seeing is a situation where your the state change causes a rerender infinite loop. Theoretically, you should be able to put anything into the formContext
. Have you debugged why you things are freezing?
Yes I've debugged, and it does seem like you're saying- it re-renders the entire component everytime 'formContext' changes. So this is an issue.
Can you suggest a work around?
Maybe you can process the formData on change in a way that you transform what you put into the formContext is only what you need to provide the auto-suggest
? Meaning if your component looks at the value of age
to auto-suggest the value of name
(from your example), perhaps precompute the suggestion OUTSIDE of the component and pass in the suggestion rather than the formData in the formContext?
Prerequisites
What theme are you using?
core
Version
5.x
Current Behavior
Inside my custom widget, it will not let me access the current formData. So I pass it into
formContext
but that breaks the form (nothing can be inputted).Expected Behavior
Inside my custom widget, I can access all the current values of the form
Steps To Reproduce
formData
to appear as a prop, but it does not, so I try passing it on formContext instead (as per issue hereI simplified my code as per below (CodeSandbox here):
Environment
Anything else?
No response