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

Any example on how to automatically open the sheet when the component mounts? #404

Open
iamvinny opened this issue Dec 28, 2024 · 1 comment

Comments

@iamvinny
Copy link

iamvinny commented Dec 28, 2024

I basically need to have the sheet popup automatically as soon as the component mount.

I've managed to achieve that by adding a delay (see example below), but this is definitely not very reliable and recommended for production. It won't work without the delay.

 useEffect(() => {
     console.log('Ref on mount:', actionSheetRef.current); // returns null
     setTimeout(() => {
         actionSheetRef.current ? .show();
     }, 500); // add a short delay to wait for component mount
 }, []);
@ammarahm-ed
Copy link
Owner

Have you tried using useLayoutEffect?``

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

No branches or pull requests

2 participants