Firt of all, thanks for the great article!
I am wondering if above the Names component you have an AddName component, with an input and add button, that adds the new name using the "API". What would be the best way to re-render Names component, since we have added a new name?
I don't have it, but that's a good suggestion!
What I would recomment to look, is the follow up article I wrote about SWR which will show you how to simplify the code above, and then you can also take a look at mutations with the SWR hook, which you can read on the official docs
Firt of all, thanks for the great article!
I am wondering if above the Names component you have an AddName component, with an input and add button, that adds the new name using the "API". What would be the best way to re-render Names component, since we have added a new name?
I don't have it, but that's a good suggestion!
What I would recomment to look, is the follow up article I wrote about SWR which will show you how to simplify the code above, and then you can also take a look at mutations with the SWR hook, which you can read on the official docs
Thanks!
I will check it...
Btw, I did build a simple todo list application, and you can see how the
mutatein SWR works by looking at this code