DEV Community

Никита Бобченок
Никита Бобченок

Posted on

The list is not updated when adding a new item via useState()

Hey, everybody

A problem (misunderstanding) has arisen with the useState hook.
I have two custom hooks:

1) useLocalStorage.ts

Image description
Used to interact with localstorage.

2) usePlaylist.ts

Image description
Used to add/remove playlists, as well as get the full playlist

I have a react component with which I add a new playlist using the usePlaylist hook

Image description

And then I have a react component that displays a list of playlists:

Image description

BUT AFTER ADDING A NEW PLAYLIST, THEIR LIST IS NOT UPDATED(only when the page is refreshed)

I have tried a lot of things, but maybe I missed something or misunderstood something, help please.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series