I have a React App for handling the front-end, and Rails for back-end. So I have a Forms Manager, in which a field can be added, previously added fields can be edited or deleted. Once made all the changes, the user can click on the Save button to send the data to the back-end.
When sending the data, which method would be more efficient?
- The component keeping track of the newly added fields, removed fields, and the modified in separate arrays and send them all to the server and let the server handle it?
- Send the fields both modified and newly added (not the deleted fields). The existing fields would have the
ids
associated to them, this tells the back-end app that it's an already existing item. This method requires the server to do a diffs method against the previously existing fields with the currently submitted fields to remove the deleted items
or is there a better alternative?