Home > other >  how to prevent list item change realtime with onchange method
how to prevent list item change realtime with onchange method

Time:12-27

I have a list that show some item, and they have Edit button beside the field, when you click the Edit button, it will show the modal that show name of the item where you can edit the name of the item. But the problem is when I try to change the name from the modal, the selected item from the list is changed too, before I click the save button.

Codesandbox

Thank you in advance.

CodePudding user response:

Don't change the parent state from the modal, create a local state in modal and pass it on to the parent in the onClose callback and then change the state in parent.

Demo: https://codesandbox.io/s/gifted-knuth-ik0ed

  • Related