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

Example with hooks not working #15

Open
AshotN opened this issue Dec 2, 2020 · 1 comment
Open

Example with hooks not working #15

AshotN opened this issue Dec 2, 2020 · 1 comment

Comments

@AshotN
Copy link

AshotN commented Dec 2, 2020

Following the example using hooks I am getting the follow error

TypeError: showConfirm is not a function

My IDE is also complaining TS2721: Cannot invoke an object which is possibly 'null'

@aadilhasan
Copy link
Owner

aadilhasan commented Dec 8, 2020

@AshotN as mounting the modal/alert is an async task that is the reason initially value of showConfirm will be null (so the user is aware of it, else calling the function before mounting won't do anything), and once it is mounted it will have a function as the value. So you must check if it's not null before you call it.

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