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

Accessing toast instance outside of component #2660

Closed
ngcvm opened this issue Jan 3, 2025 · 2 comments
Closed

Accessing toast instance outside of component #2660

ngcvm opened this issue Jan 3, 2025 · 2 comments
Assignees
Labels
nativebase-migration wontfix This will not be worked on

Comments

@ngcvm
Copy link

ngcvm commented Jan 3, 2025

Description

Hi, I have migrated from NativeBase to Gluestack V2 recently and really impressed on it. But currently, when migrating the Toast, I realize that I cannot access the toast instance directly without using the hook. So my question request is to expose a function to get the toast instance, it should be a singleton instance across the app lifecycle.

Problem Statement

My app currently first some toasts inside of the axios interceptors and I want to keep these calls.

Proposed Solution or API

Expose a helper function to get the toast instance: getToastInstance(): { show, close, closeAll, ... }.

Alternatives

No response

Additional Information

No response

@akash3gtm
Copy link
Collaborator

When we made gluestack-ui, we opted to make it more performant.
Hence we removed a lot of things that were in nativebase (e.g. conditionally rendering etc) to minimize the use of props/states and hence to avoid re-rendering and performance issues.

This decision was also one of them.

You will have to use the hook where ever you want to access the element, it internally portals to the root overlay layout only.

@akash3gtm
Copy link
Collaborator

Hope this clears things.

Closing this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nativebase-migration wontfix This will not be worked on
Projects
Development

No branches or pull requests

3 participants