An open-use web application created for easy access, collaboration, and sharing of datasets through rich metadata search, filter, sort, and direct viewing in common industry applications or in our web-based 3D Volume Viewer.
The unit tests for LazilyRenderedThumbnail were getting stalled. It seems the .useEffect was creating an infinite loop, which is apparently a common issue with React/jest.
I'm still not sure if I fully understand, but my best interpretation is that useEffect is dependent on file changes, & calling setThumbnailPath technically modifies file, so the effect runs again. Then toggling isLoading back to true triggers a re-render since the FileThumbnail component depends on isLoading, which calls useEffect again, and the loop starts all over... So our unit tests never fully finished rendering the component.
Proposed change
Since we already initialize isLoading to true and don't set it to false anywhere else, we can remove setting it to true in the effect. This way, useEffect only calls twice (once on initialization, and then once to register the change to file) and then stops.
There's also an unrelated .css change; I missed increasing the font size for thumbnail labels in #287.
Testing/Reviewing
I verified that unit tests run & finish now, but it would be great to double check that the thumbnail loading state still works as expected.
The unit tests for
LazilyRenderedThumbnail
were getting stalled. It seems the.useEffect
was creating an infinite loop, which is apparently a common issue with React/jest.I'm still not sure if I fully understand, but my best interpretation is that
useEffect
is dependent onfile
changes, & callingsetThumbnailPath
technically modifiesfile
, so the effect runs again. Then togglingisLoading
back to true triggers a re-render since theFileThumbnail
component depends onisLoading
, which callsuseEffect
again, and the loop starts all over... So our unit tests never fully finished rendering the component.Proposed change
Since we already initialize
isLoading
to true and don't set it to false anywhere else, we can remove setting it to true in the effect. This way,useEffect
only calls twice (once on initialization, and then once to register the change tofile
) and then stops.There's also an unrelated .css change; I missed increasing the font size for thumbnail labels in #287.
Testing/Reviewing
I verified that unit tests run & finish now, but it would be great to double check that the thumbnail loading state still works as expected.