79504287

Date: 2025-03-12 16:43:54
Score: 0.5
Natty:
Report link

Yes you want the team to be visible immediately in the table, you would have a function called for example handleAdd that will send a fetch request to add the team and then return the inserted row id, then you would insert that id along with other data in the state, the id is required if user want to edit or delete the item by id, then the table will be updated when you set the state, there is no need to call fetchTeams after add, only call it once as the initial data, so put it and call it inside useEffect, the array of dependencies should be empty

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Aasem Shoshari