react-image-lightbox
react-image-lightbox copied to clipboard
Loading icon gets stuck in React 18 dev mode
I ran into this issue in React 18 app using strict mode.
The lightbox never shows the first image, but instead, it keeps showing a loading icon. The images start showing fine only after I click the previous/next buttons.
Demo: https://codesandbox.io/s/github/igordanchenko/react-photo-album/tree/v1.12.0/examples/lightbox
Steps to reproduce:
- Open the above link
- Click any image
This issue is related to the following change in React 18:
React 18 introduces a new development-only check to Strict Mode. This new check will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous state on the second mount.
https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-strict-mode
While this bug is currently visible only in dev mode, it highlights that similar issues may occur in production in the future.
Any update on this issue?
same issue
Same issue, if you resize the window the current image appears
Having the same issue
same issue
Found temp hack to solve the problem (tested on chrome only):
{lightBoxImage && (
<Lightbox
mainSrc={lightBoxImage}
onImageLoad={() => {
window.dispatchEvent(new Event('resize'));
}}
onCloseRequest={() => setLightBoxImage(null)}
/>
)}
Same problem here, but at least @ihappycoder 's hacky fix worked
If anyone is looking for an alternative to react-image-lightbox, here is the recently released lightbox library - yet-another-react-lightbox. All feedback is welcome.
Same issue, if you resize the window the current image appears
same here
Same issue
Same, please fix
https://www.npmjs.com/package/react-18-image-lightbox
I have this issue on react-18-image-lightbox and original versions.
With "hacky fix" - issue gone, only have little longer loading time.
https://www.npmjs.com/package/react-18-image-lightbox
Is this a separate package for react-18? looks like the readme is not updated properly https://www.npmjs.com/package/react-18-image-lightbox?activeTab=readme
Looks like the library frontend-collective/react-image-lightbox will not be maintained anymore. Really a pity.
ihappycoder THANKS A LOT❤️ You saved my life 😘
Work with me, node v18.2.0, thank you.
onImageLoad={() => window.dispatchEvent(new Event("resize"))}
fixed it for me