We’re using JSONForms with React. Some of our forms are quite large, so we’ve split them into sections for improved performance, and we maintain the form and UI schemas for the separate sections in a database, and then render multiple form sections on the page at the same time using multiple instances of the JSONForms component. Ultimately we want to merge the form data together, so we use a common onChange handler; we invoke it with a “part number” so that we know which part is being modified. Basically, like this:
onChange={dataAndErrors => ourFormChangeHandler(partNumber, dataAndErrors)}
So the challenge we’re having is: we need to know if ANY of the form “parts” have validation errors, so that we can disable the “submit” button. This all works fine as the user makes changes to individual fields. But on init, when the multiple form parts are first rendered, our form change handler gets called by each of the instances of the JSONForms component, and those calls happen asynchronously. We’ve had to jump through some hoops in order to capture all of the data in our container’s state, as well as the presence of any validation errors. And since our change handler doesn’t know whether it’s being invoked due to a change by the user vs. at init time, we have to take the careful approach in all cases; it seems to be working, but performance is not ideal. If the onChange callbacks during init were synchronous, we could do it in a more straightforward way (or, if there were an additional parameter passed in, telling us that it was happening at init time).
Are there any suggestions for how we might approach this in a different way?
[original thread by Kevin Ilsen]