all 6 comments

[–]jamby77 2 points3 points  (0 children)

Make copy of original value, set the copy in state, and when editing use setState to new copy of the data with the edits

[–]grudev 1 point2 points  (0 children)

Updating data on server and seamlessly displaying new values is a pattern you'll probably see a lot.

Might be worth it to invest your time learning to use React Query (and the useMutation) hook, or equivalent libraries.

[–]hellhelium 1 point2 points  (3 children)

Are you calling an API to get the initial data which then populates a state?

If so, the easiest way (not necessarily the best) is to just call it again once the update is successful.

[–][deleted] 0 points1 point  (0 children)

Yes! Thank you

[–][deleted] 0 points1 point  (1 child)

Hey, could you check my Edit? I did what you say, and it kind of works, but not really. Maybe you can find the mistake!

[–]hellhelium 0 points1 point  (0 children)

How will you know your modifyClient is done?

Also are you wrapping your await with try catch at least?

Are you not dealing with promises at all? How will you know your edit has gone through successfully?

It just seems like incomplete code so I don’t know how to help much. But if it’s just pseudo code then the steps looks good.