DEV Community

Discussion on: A practical example of Suspense in React 18

Collapse
 
matheus6_6 profile image
Matheus Barbosa

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?

Collapse
 
darkmavis1980 profile image
Alessio Michelini

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

Collapse
 
matheus6_6 profile image
Matheus Barbosa

Thanks!

I will check it...

Collapse
 
darkmavis1980 profile image
Alessio Michelini

Btw, I did build a simple todo list application, and you can see how the mutate in SWR works by looking at this code