I am using react hook form to assist with managing a complex set of data with parent child relationships, and I think i’m deleting elements incorrectly. I can add, save and edit the child elements fine. but when I try to delete them, I am currently making a round trip to the API to delete the child by id, then redirecting back the parent display.
But I think I am doing this wrong. With react hook form I should be able to manage the state locally (through the fieldset), and when I delete a child element I don’t have to do any trips to the database until I am ready to save the form, and at that time I can do a PUT to update the child elements all at once, right?
My code is kind of a mess between using radix UI and the number of fields I’m displaying so I just want to see if my execution is the wrong way of thinking. Of couse I can add it if you do want to see it.
I have been looking at this:
And while the sandbox doesn’t use a back end, there’s no reason I should be able to do the same thing, and then take the final json object and send that to my API for the parent component, right?
I’m having a mini meltdown over this, so if you can help clarify, I would really appreciate it. I think I just need to talk this through.
Thank you.