79341665

Date: 2025-01-09 07:15:22
Score: 0.5
Natty:
Report link

I think the issue is you're using data.id to render but for the delete logic, you're using session.id

data.id should be session.id? as you're already using data to map, and have session as a key here:

{data.map((session) => {
...
<li key={data.id}> // typo? session.id*

I think this is the reason why you see changes in the backend, but changes aren't reflected in the front end


also to guarantee latest update, I would utilize with prevData based on the value of the old state of the component:

setData(prevData => prevData.filter(s => s.id !== session.id));

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: tim