-
Notifications
You must be signed in to change notification settings - Fork 98
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
Running alert.show
inside useEffect
causes infinite loop
#119
Comments
Hi, @amillward. What can I tell you - in your code So, you need to pass to |
Omitting |
I found a solution for you in one of the React issues. Please, have a look into this sandbox in issue facebook/react#15204 |
ah yes - I actually tried wrapping with But would it be appropriate to wrap these functions within the react-alert module itself? It should work the same I believe. Otherwise anyone who wishes to show an alert as a result of an effect - I assume fairly common for things like errors loading the content on a page - has to create this arbitrary wrapper every time. |
It won't work the same, because your component is a functional component. On every re-render, the new component with the new link to the From my point of view, I'm considering the I assume, that Anyway, I think, that you should take a look at these React issues: facebook/react#14920, facebook/react#15204 where people discuss the same problem as you have. Also, I'm also closing this issue, because it's not the drawback of this particular repo. |
I have a functional component that loads data inside a
useEffect
. I'm required to providealert
as a dep, however doing so causes an infinite loop.CodeSandBox here: https://codesandbox.io/s/mystifying-rubin-dhbov
The text was updated successfully, but these errors were encountered: