-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Hi! π
Firstly, thanks for your work on this project! π
I am using the Gallery component outside of a virtualized table with cells that include an Item component. When scrolling away such an Item, which results in unmounting of the row becuase of virtualization, the Gallery should remove it from its items ref map. Because this is not happening, when scrolling back up to the row with that Item, trying to open it will result in an error from ensureRefPassed.
I used patch-package to fix it.
Here is the diff that solved my problem:
diff --git a/node_modules/react-photoswipe-gallery/dist/gallery.js b/node_modules/react-photoswipe-gallery/dist/gallery.js
index 04bd441..fce6c69 100644
--- a/node_modules/react-photoswipe-gallery/dist/gallery.js
+++ b/node_modules/react-photoswipe-gallery/dist/gallery.js
@@ -284,6 +284,10 @@ export const Gallery = ({
items.current.delete(ref);
}, []);
const set = useCallback((ref, data) => {
+ if (ref.current === null) {
+ return;
+ }
+
items.current.set(ref, data);
if (openWhenReadyPid.current === null) {
return;
diff --git a/node_modules/react-photoswipe-gallery/dist/item.js b/node_modules/react-photoswipe-gallery/dist/item.js
index 344d904..3db2a60 100644
--- a/node_modules/react-photoswipe-gallery/dist/item.js
+++ b/node_modules/react-photoswipe-gallery/dist/item.js
@@ -45,9 +45,7 @@ export const Item = _a => {
}), [refCallback, open, close]);
useEffect(() => {
return () => {
- if (ref.current === null) {
- remove(ref);
- }
+ remove(ref);
};
}, [remove]);
return children(childrenFnProps);This issue body was partially generated by patch-package.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels