After edit record in datatable, only first entry from backend is displayed using react

Viewed 17

I have edit/delete functionality for records. when I come on actual page, it displays all data but when I actually edit/delete. Only first entry from cloudant is displayed. But if I again click on edit/delete functionality it displays all data. Must be issue with react state.

Adding details about my implementation. state: state in useEffect I used Carbon components DataTable for rendering countryDetList data. After edit/delete and Modal closing, only 1st record is displayed.

1 Answers

Becuase the state is not re-rendering

Check what are you setting in state if you are using objects in state check how you are setting them for example

  const [User,SetUser] = React.useState({})
    
    SetUser({id:21})
    
    this might not be cause a re-render
    SetUser({id:26})
    
    you can make it like
    
    SetUser({...{},...{id:26

}})
Related