I have various different places throughout my JSON forms app where I edit the data not using the controls on the page. For example I have an import functionality that reads in a JSON file of a different format and creates a data object that follows my schema definition. There are multiple places within my application where I modify the data object like this.
My current approach involves me creating an empty data object and a function to modify it at the top level of my application:
const [data, setData] = useState<MyDataType>();
and then passing the setData throughout my application to any component that requires it. This works fine in a few cases but having recently read about contexts in React I suspect that perhaps it’s not the best way to do things.
My approach to updating data is also inconsistent in that I use the method mentioned above in my custom non json forms components but in my customised JSON forms controls/renderers etc I make use of the addItems, removeItems functions that are provided.
is there a best practise for updating data outside of the controls?