xcarpentier / react-native-country-picker-modal

🇦🇶 Country picker provides a modal allowing a user to select a country from a list. It display a flag next to each country name.
https://reactnative.gallery/xcarpentier/country-picker
MIT License
1.07k stars 796 forks source link

VirtualizedLists should never be nested inside plain ScrollViews... fix #455

Closed Cmoen11 closed 2 years ago

Cmoen11 commented 2 years ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-country-picker-modal@2.0.0 for the project I'm working on.

I had some issue with an error VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing and other functionality - use another VirtualizedList-backed container instead.

And it was caused by having the modal loaded without even needing it to be loaded. So I unloaded it when it is not in use.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-country-picker-modal/lib/AnimatedModal.js b/node_modules/react-native-country-picker-modal/lib/AnimatedModal.js
index 01f0408..6cced6b 100644
--- a/node_modules/react-native-country-picker-modal/lib/AnimatedModal.js
+++ b/node_modules/react-native-country-picker-modal/lib/AnimatedModal.js
@@ -23,6 +23,11 @@ export const AnimatedModal = ({ children, visible }) => {
             hideModal();
         }
     }, [visible]);
+
+    if(!visible) {
+        return null;
+    }
+
     return (React.createElement(Animated.View, { style: {
             ...StyleSheet.absoluteFillObject,
             transform: [{ translateY }],

This issue body was partially generated by patch-package.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.