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

Picker component performance issues on iOS with larger items #1239

Closed
aligfl opened this issue Sep 19, 2017 · 6 comments
Closed

Picker component performance issues on iOS with larger items #1239

aligfl opened this issue Sep 19, 2017 · 6 comments

Comments

@aligfl
Copy link

aligfl commented Sep 19, 2017

Hi,
I'm seeing some performance issues when using the Picker component with large items on iOS.

react-native, react and native-base version

...
"native-base": "^2.3.1",
"prop-types": "^15.5.10",
"react": "16.0.0-alpha.12",
"react-native": "^0.46.0",
...

Expected behaviour

Picker to quickly close when an item is selected or back button is pressed.

Actual behaviour

There is a 3~4 second lag when either an item is selected or back is pressed on iOS

Steps to reproduce (code snippet or screenshot)

  1. Use the following picker, with around 800 items.
  2. Open the Picker by clicking on it
  3. Press back OR select an item from the list.
    <Picker
      selectedValue={5}
    >
      {
        Array(800).fill().map((e,i)=>i+1).map((i, index) => (
          <Item label={i} value={i} key={i} />
        ))
      }
    </Picker>

Screenshot of emulator/device

sep-18-2017 21-33-02

Is the bug present in both ios and android or in any one of them?

just iOS.

Any other additional info which would help us debug the issue quicker.

@akhil-ga
Copy link
Contributor

@aligfl 800 items in picker is a very large number. We don't generally use such a large number of items in picker. If there is any valid use case, let us know.

@aligfl
Copy link
Author

aligfl commented Nov 23, 2017

@akhil-geekyants this is a use case for our app. Where we have a list of items that we need to pick from. Infact ours is around even more. I used 800 just as an example. It would be great if the performance problem can be fixed.

It would be amazing if you guys added a "Search Bar" at the top to search the list of item from the picker.

@SupriyaKalghatgi
Copy link
Contributor

@aligfl We will have React Native's FlatList with NativeBase Picker

@brunolemos
Copy link

brunolemos commented Dec 1, 2017

@aligfl

You should not use .map with big lists, use FlatList instead.
Your 800 items are being regenerated on each rerender.

Also, avoid using index as keys (on this example it might be ok).

This seems to be a normal list performance issue, not necessarily related to Picker.

akhil-ga added a commit that referenced this issue Dec 11, 2017
Replaced ListView with FlatList in Picker
SupriyaKalghatgi added a commit that referenced this issue Dec 21, 2017
Possible Fix for issue #1239. Replaced ListView with FlatList in Picker
@SupriyaKalghatgi
Copy link
Contributor

Fixed with 2.3.6

@neekey
Copy link

neekey commented Apr 16, 2019

I'm still having this performance issue with version ^2.12.1. In my case, I only have around 150 items.

The main problem I can observe is that the rendering of the items happens even the List is not active, say I have this edit page with this big picker, when I click a link from another page to this edit page, the screen will freeze for several seconds, then the edit page appears.

the list should only be rendered when the picker is active IMO

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

No branches or pull requests

5 participants