Handling state changes with toast #1132
-
tl;dr: I am trying to add a universal toast on Console and the state management is causing issues. I am trying to implement toast in console and trying to make it universal so anyone who uses it will have the toast for their pages in queue in the same array. Right now, if two different apps (or more) use toast.movhttps://codesandbox.io/s/mystifying-architecture-0yj9n?fontsize=14&hidenavigation=1&theme=dark In Console, I am trying to put the toast on the top level, wrapping the rest of the components, and this causes a re-render every time useToaster is called because it returns a new object every time. Is there a way to change the state management with |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hi @bvsillorequez I'm not entirely sure I follow, are these two distinct observations? Do you mind rewording slightly? Also, unfortunately it looks like the codesandbox didn't save, so when I visit the link I just see the default template. |
Beta Was this translation helpful? Give feedback.
-
Hi @bvsillorequez - we don't have an answer for you yet, but we're still looking into this and discussing internally. Will keep you posted. |
Beta Was this translation helpful? Give feedback.
-
Hi again @bvsillorequez,
So we spoke about this at length internally and right now the best thing for you to do, as a Console product team, is to build your own state management for Toasts. You'll also get full control of what (re-)renders and will be able to handle message passing with Console's Navigation bundle. If you look at this example: https://paste.twilio.design/components/toast#adding-a-toast We aren't able to provide this functionality in our component because it couples application logic with the component's presentation. Console's specific requirements around shared state between Navigation and Products doesn't quite fall within the purview of a design system, and such a feature can add unneeded complexity to our other users. |
Beta Was this translation helpful? Give feedback.
Hi again @bvsillorequez,
So we spoke about this at length internally and right now the best thing for you to do, as a Console product team, is to build your own state management for Toasts. You'll also get full control of what (re-)renders and will be able to handle message passing with Console's Navigation bundle. If you look at this example: https://paste.twilio.design/components/toast#adding-a-toast
useToaster
is where all the state management lives. You will still be able to us…