Always confirm first
Deletion is the one operation you can’t undo. Always ask the user to confirm before deleting.- Backend (Python)
- API Client (JS)
Simple confirmation with window.confirm
The quickest approach — a browser-native confirmation dialog:window.confirm() is perfectly fine for admin tools and internal apps. It’s ugly but it works.
Custom confirmation UI
For a better user experience, build your own confirmation:confirming (are we showing the confirmation?) and deleting (is the API call in progress?). The user clicks Delete → sees “Yes, delete” / “Cancel” → confirms → item is removed.
Updating the parent’s state
The parent removes the deleted item from its list:.filter() creates a new array without the deleted item. This is the standard pattern for removing items from a list in React.
prev.filter(u => u.id !== userId) keeps every user whose ID does NOT match the deleted one. Simple, immutable, and correct. You’ll use this pattern alongside .map() for updates and [...prev, newItem] for creates.The three state update patterns
You now have all the CRUD state updates:What’s next?
You’ve built all four CRUD operations. Now let’s see the complete picture — a full example with everything wired together from backend to frontend.Full example walkthrough
See a complete CRUD application with React and FastAPI working together