WIP Reload lazy load props in WhenVisible when they become undefined #2392
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an attempt to fix #2388 but it's not finished, it has some bugs.
It works when using the prop without the always attribute, but I'm struggling to make it work when it is true.
Since we cannot rely on useEffect to check if props are changed, because it will throw error before calling them, I switched the loading state to a ref and using an useMemo to check if props are changed checking that they are not undefined.
I then added the loading value to the useEffect so that when it change from true to false, it reload the props, but this will make it run twice, it make another request when it pass from false to true. I tried blocking it if props are loaded but this will make the always prop not work anymore.
I'm also having problem with current tests on WhenVisible component: