Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtualizedlist should never be nested inside scrollview #56

Closed
cbothra opened this issue Jul 8, 2020 · 45 comments
Closed

Virtualizedlist should never be nested inside scrollview #56

cbothra opened this issue Jul 8, 2020 · 45 comments

Comments

@cbothra
Copy link

cbothra commented Jul 8, 2020

I am using this dropdown plugin in a scrollview and getting a following warning:

VirtualizedLists should never be nested inside plain ScrollViews with the same orientation - use another VirtualizedList - backed contained instead.

Any help would be highly appreciated.

Thank-in-advance.

@usersina
Copy link

usersina commented Jul 8, 2020

If you comment out the ScrollView, does the dropdown by any chance stay behind the other components if you open it ?
Sort of like this.

@cbothra
Copy link
Author

cbothra commented Jul 9, 2020

Nope the dropdown works just perfect. All I am facing is this warning Virtualizedlist should never be nested inside scrollview. I googled this error and there are some solutions for this. This is a common error which appears when we put a Flatlist inside Scrollview. I was not sure how to resolve that in the plugin plus I dont want to alter the node modules packages. So I thought to bring it to your notice.

I am taking body measurements in my app which can be in inch/cms and pounds/kg . So I wanted to have dropdown along side each input. And all these measurements inputs are wrapped in a Scrollview container.

@hossein-zare
Copy link
Owner

hossein-zare commented Jul 9, 2020

Hello @cbothra ,
Before updating the package, I did some research on how to use FlatList inside ScrollView, I ended up with these:
https://stackoverflow.com/questions/51098599/flatlist-inside-scrollview-doesnt-scroll
https://reactnative.dev/docs/scrollview#nestedscrollenabled

<ScrollView nestedScrollEnabled={true} />
    <DropDownPicker  ... />
</ScrollView>

If the example doesn't solve the problem, please let me know.

Update

Update the package to v3.1.8.

@usersina
Copy link

usersina commented Jul 9, 2020

I also have the same warning, tried adding nestedScrollEnabled={true} but it didn't work.
I should note that my app looks like this:

App.js:

<ScrollView nestedScrollEnabled={true} />
    <SomeComponent1 />
    <SomeComponent2 />
    <TheDropView />
</ScrollView>

TheDropView.js:

<View style={{flexDirection: 'row'}}>
    <DropDownPicker  ... />
</View>

@kimkong88
Copy link

Same issue here, One way to fix is have horizontal ScrollView wrapped outside of dropdown, it will make the warning disappear, but obviously not a right solution.

@cbothra
Copy link
Author

cbothra commented Jul 10, 2020

@hossein-zare Nope, just adding nestedScrollEnabled={true} didn't worked. Also note that I updated the library to the latest version.

My case is exactly same as @usersina.

@kimkong88 This hack works but yes you are are right. This is not an optimal solution. Besides that you have to give height to the scrollview so that the options gets displayed.

@hossein-zare
Copy link
Owner

hossein-zare commented Jul 10, 2020

@cbothra @usersina @kimkong88

I got rid of FlatList, ScrollView replaced.

New update: 3.1.9

@cbothra
Copy link
Author

cbothra commented Jul 10, 2020

Doesn't make any difference. Warning still persists. I think its not related to flatlists or scrollview. The core problem is using scrollview/flatlist inside another scrollview/flatlist.

@hossein-zare You should checkout this link for solutions: GeekyAnts/NativeBase#2947

@hossein-zare
Copy link
Owner

Make sure you're using v3.1.9, The warning has to go away.

@usersina
Copy link

Solved !

@singhprabhanshu
Copy link

singhprabhanshu commented Jul 11, 2020

No, warning is there in version 3.1.9. i have installed and configured it. Also the scroll of dropdown option is not going to happen if we are using it inside scrollView or content(native base). To scroll option of dropdown inside scroll view, i need to press scroll view and then scroll is going to happen on dropdown option. Anybody have solution??

@cbothra
Copy link
Author

cbothra commented Jul 14, 2020

@hossein-zare Yep Now I can confirm that there is no more Yellow Box Warning.

Btw just out of curiosity what was your solution. I hope you didn't just hide the warning :D (Just Kidding).

@hossein-zare
Copy link
Owner

I replaced FlatList with Scrollview

@codoffer
Copy link

codoffer commented May 14, 2021

I am facing the same issue. Getting a warning - "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."

I have fixed this by using a different mode

https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/5.0/advanced/list-modes#scrollviewprops

@hossein-zare
Copy link
Owner

@codoffer
If that happens, You have to use listMode="SCROLLVIEW" or listMode="MODAL".

@hossein-zare hossein-zare pinned this issue May 14, 2021
@alessandro-bottamedi
Copy link

Problem still happens in ver 5.1.17 (solved with listMode="SCROLLVIEW")

@SatalBill
Copy link

SatalBill commented Jun 7, 2021

@alessandro-bottamedi and @hossein-zare 's answers saved my time.

<DropDownPicker
  open={open}
  value={value}
  items={items}
  setOpen={setOpen}
  setValue={setValue}
  setItems={setItems}
  style={{backgroundColor: 'crimson',}}
  listMode="SCROLLVIEW"                      // This line solved my issue.
/>

Reference link is here

@impe93
Copy link

impe93 commented Jun 16, 2021

This configuration worked form me:

<ScrollView nestedScrollEnabled={true}> // Add nestedScrollEnabled={true}
  <DropDownPicker
    open={open}
    value={value}
    items={items}
    setOpen={setOpen}
    setValue={setValue}
    setItems={setItems}
    listMode="SCROLLVIEW" // Add this line 
  />
</ScrollView>

@Paramesh98
Copy link

Hi, I had the same issue, the library provides listMode props. Adding this props solved my issue.

 listMode="SCROLLVIEW"
        scrollViewProps={{
          nestedScrollEnabled: true,
  }}

check this documentation for more information https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/next/advanced/list-modes#scrollviewprops

@Nouhack
Copy link

Nouhack commented Jun 24, 2021

the way to avoid this type of warning was mentioned in the doc , please take a look :
https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/advanced/list-modes#notes

@fajarprayoga
Copy link

Saya menghadapi masalah yang sama. Mendapatkan peringatan - "VirtualizedLists tidak boleh bersarang di dalam ScrollViews biasa dengan orientasi yang sama karena dapat merusak jendela dan fungsionalitas lainnya - gunakan wadah lain yang didukung VirtualizedList sebagai gantinya."

Saya telah memperbaikinya dengan menggunakan mode yang berbeda

https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/5.0/advanced/list-modes#scrollviewprops

this work for me

@ironwebstar
Copy link

ironwebstar commented Sep 2, 2021

Still not working on my end.
when the dropdown position is top, it's working as expected, but on bottom, still overlapped and unable to select.

@mikehardy
Copy link
Collaborator

@ironwebstar I won't have time to troubleshoot your project personally, however in general for anyone to help anyone you should do your best to produce a https://stackoverflow.com/help/minimal-reproducible-example

@Satyam-code143
Copy link

I am not getting any error but the listMode="SCROLLVIEW" doesn't open the dropdown. I don't want to use MODAL in my app. So, please can someone help.

I have created a project over Snack. DropDown. In this project, it is working on the web but it isn't showing up on mobile, please help me out to solve this.

Thank You!!

@Roundups
Copy link

I am also having issues, it works ok on iOS but not on android. It will open the dropdown but I can't then scroll or choose another option within the dropdown. I am using listMode="MODAL" for the time being.

@fadinasr
Copy link

fadinasr commented Nov 5, 2021

@hossein-zare do we lose any performance if we use Scroll View instead of Flat List? keep in mind the items are pretty simple text items.

@hossein-zare
Copy link
Owner

Hello @Satyam-code143 @Roundups ,

Unsolvable, Consider using a View element instead of the ScrollView

@hossein-zare
Copy link
Owner

hossein-zare commented Nov 5, 2021

@fadinasr
It depends on the number and simplicity of your items.
If they are +(~20), it'll impact the performance.

@PranatoshRoy
Copy link

PranatoshRoy commented Jan 26, 2022

Hi, I had the same issue, the library provides listMode props. Adding this props solved my issue.

 listMode="SCROLLVIEW"
        scrollViewProps={{
          nestedScrollEnabled: true,
  }}

check this documentation for more information https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/next/advanced/list-modes#scrollviewprops

Wroks like a charm. Thanks @Pramesh98

@DracoZona
Copy link

@alessandro-bottamedi and @hossein-zare 's answers saved my time.

<DropDownPicker
  open={open}
  value={value}
  items={items}
  setOpen={setOpen}
  setValue={setValue}
  setItems={setItems}
  style={{backgroundColor: 'crimson',}}
  listMode="SCROLLVIEW"                      // This line solved my issue.
/>

Reference link is here

This works for me.

@Mukthayar1
Copy link

@codoffer If that happens, You have to use listMode="SCROLLVIEW" or listMode="MODAL".

@hossein-zare
listMode="SCROLLVIEW" its make list very slow

@amirVirtuenetz
Copy link

Hello @cbothra , Before updating the package, I did some research on how to use FlatList inside ScrollView, I ended up with these: https://stackoverflow.com/questions/51098599/flatlist-inside-scrollview-doesnt-scroll https://reactnative.dev/docs/scrollview#nestedscrollenabled

<ScrollView nestedScrollEnabled={true} />
    <DropDownPicker  ... />
</ScrollView>

If the example doesn't solve the problem, please let me know.

Update

Update the package to v3.1.8.

I have tried your solution but i faced the error same like that
i ahve a ScrollView in main Container of Screen and inside multiple children like input button and alos Dropdown picker
but i cannot resolve the issue
i am using
"react-native-dropdown-picker": "^5.4.2",
"react-native": "0.68.2",

@amirVirtuenetz
Copy link

@alessandro-bottamedi and @hossein-zare 's answers saved my time.

<DropDownPicker
  open={open}
  value={value}
  items={items}
  setOpen={setOpen}
  setValue={setValue}
  setItems={setItems}
  style={{backgroundColor: 'crimson',}}
  listMode="SCROLLVIEW"                      // This line solved my issue.
/>

Reference link is here

This works for me.

Thanks , it solved my issue

@TommysG
Copy link
Contributor

TommysG commented May 31, 2022

Hello @Satyam-code143 @Roundups ,

Unsolvable, Consider using a View element instead of the ScrollView

@hossein-zare Have you consider changing a little bit the implementation and render the dropdown inside a modal( and inside the modal the flatlist) and place it exactly under the dropdown button with the same width as the button container? I think this will solve all the compatibility problems between iOS & Android (nested scrolls etc) and the z-index bugs.

@hossein-zare
Copy link
Owner

@TommysG

Modals are fixed (position) on the screen so if you scroll up and down, the modal won't move.

@TommysG
Copy link
Contributor

TommysG commented Jun 1, 2022

@hossein-zare

Yes. The concept is that if you touch anything outside the dropdown(modal) or if you try to scroll on the parent container, then close the dropdown.

@zulkifli0201
Copy link

Saya menghadapi masalah yang sama. Mendapatkan peringatan - "VirtualizedLists tidak boleh bersarang di dalam ScrollViews biasa dengan orientasi yang sama karena dapat merusak jendela dan fungsionalitas lainnya - gunakan wadah lain yang didukung VirtualizedList sebagai gantinya."

Saya telah memperbaikinya dengan menggunakan mode yang berbeda

https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/5.0/advanced/list-modes#scrollviewprops

thankyou

@wanderlust252
Copy link

this work well on IOS but android, it didn't show the list

@AshuInsideOut
Copy link

AshuInsideOut commented Dec 16, 2022

I added both but it doesn't seems to work. Modal works but I want the list

image
image

It doesn't show the dropdown list

@umairm1alik
Copy link

If I use listemode = 'SCROLLVIEW' it makes dropdown performance very slow and if I use 'FLATLIST' dropdown become not scrollable plus virtualization warning.

@tragicmj
Copy link

tragicmj commented Feb 6, 2023

I can completely relate to @umairm1alik , facing the same issue. If I use Flatlist see virtualization warning and if I use Modal, freezing issue.

@AshuInsideOut
Copy link

AshuInsideOut commented Feb 6, 2023

Yes, you are right. It's really feel slow and weird.

@Bayramito
Copy link

the issue still existing with the latest version

@Jeeet-patel
Copy link

I am not getting any error but the listMode="SCROLLVIEW" doesn't open the dropdown. I don't want to use MODAL in my app. So, please can someone help.

I have created a project over Snack. DropDown. In this project, it is working on the web but it isn't showing up on mobile, please help me out to solve this.

Thank You!!

@Satyam-code143 Try giving height to the container of dropdown component i tried it worked for me

@williamlegane
Copy link

Add this if you are struggling with DropDownPicker inside ScrollVide

DropDownPicker.setListMode("SCROLLVIEW");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests