React How to Delete an Element From a State Array

preview_player
Показать описание
How to delete an element from an array held in useState in React.

📣 Follow Coding in Flow on social media:
Рекомендации по теме
Комментарии
Автор

Discovered this through in your MERN course. Still ongoing. Thank you.

zeus
Автор

Your 2d unity tutorial really helped me thank you

loaf
Автор

Hey thanks for this! Im using typescript with supabase. My code is also similar:

const handleDeleteLink = (linkId: number) => {
// Call the deleteLink function and update the state
deleteLink(linkId);
// Remove the link from the state to update the UI.
setLins((lins) => lins.filter((link) => link.link_id !== linkId));
};

However, when i delete, it deletes from database but doesnt show in ui until unless i manually refresh. How should I go about this?

appstuff