An example using React and Zustand.
In this example I show a list of todos (the todos was loaded from jsonplacehokder API). With a button, that shows "Add todo", you can add a todo to a list (local state), managed by zustand. If the todo is added to the list, the message from the button changes and the function too. The message changes to "Remove todo" and the function is to remove the todo from the list. And again the button changes the message to "Add todo". The list of todos selected is visible in the browser console.