-
-
Notifications
You must be signed in to change notification settings - Fork 463
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
WhenVisible useEffect function is not recreated when params change. #2152 #2153
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @Loeffeldude !!
Thanks for the PR @Loeffeldude. I'm a little confused as to why the |
We split into two refs (fetchedOnceRef and fetchingRef) because we're handling two distinct problems: Has this content ever been fetched? (for the always prop logic) Using a single useState for fetching would create problems because: State updates are asynchronous and will trigger rerenders Using refs:
The ref-based approach is more robust for handling edge cases and async behavior. |
Thanks for the info @Loeffeldude, much appreciated! |
Closes #2152. Adds the needed dependencies to the useEffect and adds a few refs to keep the same fetching behavior as before.