Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Toast messages #1098

Closed
Traxmaxx opened this issue Oct 16, 2023 · 5 comments
Closed

Refactor Toast messages #1098

Traxmaxx opened this issue Oct 16, 2023 · 5 comments
Assignees

Comments

@Traxmaxx
Copy link
Contributor

Traxmaxx commented Oct 16, 2023

Toasts are difficult to use and always need to be imported manually if not there already. We would like to address this and have one global instance where we would like to send notifications to. This requires some specific way of state handling or global state.

Our current Toast hook lives inside /dashboard/components/toast/hooks/useToast.tsx.
We would like to have one running instance of Toasts which we can keep on reusing. Similar to a singleton. Tha would allow us to just call setToast from wherever we want without need to always import {toast && <Toast {...toast} dismissToast={dismissToast} />} or pass down setToast multiple levels!

This needs to have some sort of state management for it to work like expected though. Let's brainstorm possible solutions in this Issue thread before implementation 🙏

Additional context
If you want to tackle this task, feel free to share with us your email address so we can give you access to the Figma project :)

@shavidze
Copy link
Contributor

shavidze commented Oct 17, 2023

What about creating a context for it an wrapping the application ?
Another solution that comes to my mind is to use React Portals and this way render our Toasts.

@Traxmaxx
Copy link
Contributor Author

What about creating a context for it an wrapping the application ? Another solution that comes to my mind is to use React Portals and this way render our Toasts.

That could certainly work!

@shavidze
Copy link
Contributor

@Traxmaxx Can I take it?

@Traxmaxx
Copy link
Contributor Author

@Traxmaxx Can I take it?

Absolutely, it is all yours!

@Traxmaxx
Copy link
Contributor Author

Fixed in #1112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants