NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Very slowly perfermance when there is some ListItem in one page.

Open Symous opened this issue 9 years ago • 22 comments

Hi ,there are some ListItem(about 6-7) in one page of my program(Android Platform),And I found that when I click a button to enter this page(with some ListItem),it will have a 1-3 scends delay before I totally enter the page, And the switch animation is not smooth enough too.

And after that I have made a custom ListItem component of myself and replace the ListItem of nativebase,when I test to press a button to enter this page again.it work much better,but the switch animation is still not smooth.

So,it prove that the ListItem component of nativebase is not "perfect" enougn.and I aslo have run the demo app of native base, it also slowly when we open a page when there is ListItem exist.

Do you have any idea about that and how to solve this.It's an urgency for me. Thank you!

Symous avatar Apr 20 '17 09:04 Symous

+1 I have performance issue too. 😞

cyclops24 avatar May 06 '17 08:05 cyclops24

#625

SupriyaKalghatgi avatar May 29 '17 07:05 SupriyaKalghatgi

Hi @Symous @cyclops24 , We tried replicating what you suggested but did not encounter any problems. Some more information might help like are you using images in your ListItems. Also, attach some code snippets or GIF's to make this clearer.

Jasbir23 avatar Jun 08 '17 07:06 Jasbir23

@Jasbir23 Hi, in my app I have about 7 - 8 of the below ListItem in one page.

<ListItem icon>
        <Left>
          <Button style={{ backgroundColor: '#FD3C2D' }} onPress={()=>{alert(oo.id);}}>
            <Icon active name="notifications" />
          </Button>
        </Left>
        <Body>
          <Text>Notifications</Text>
        </Body>
        <Right>
          {(Platform.OS === 'ios') && <Icon active name="arrow-forward" />}
        </Right>
      </ListItem>

// some similar ListItem here... 

and everytime I enter this page, the perfermance is just so bad. :-)

Symous avatar Jun 08 '17 12:06 Symous

@Symous I need a little more than that. Like, versions of RN and NB. What navigation are you using. Also a GIF showing the performance problem will help us solve this quicker. Thanks :-)

Jasbir23 avatar Jun 09 '17 06:06 Jasbir23

@Jasbir23 please see #1024 for see more detail about this bug. @Symous Are you find any working solution about this or stop using NativeBase List component?

mnlbox avatar Jul 16 '17 09:07 mnlbox

@Jasbir23 Hi,sorry for the delay.

this is the version information React-Native : 0.45.1, Native-Base:2.1.2 navaigation: react-native-router-flux : 3.38.0 (Also test with react-navigation,and turned out same result)

In fact I have replace the ListItem with a custom component just like it. what I can say is that ListItem works not fluently enough, the animation when we enter a page with some ListItem perform so slowly,,,

Symous avatar Jul 21 '17 02:07 Symous

@mnlbox Hi,I guess the best way for now is that create a similar custom component to replace ListItem....

Symous avatar Jul 21 '17 02:07 Symous

@Symous I used to have perf issues with react-native-router-flux. Could you try using react-navigation instead?

sebasgarcep avatar Aug 12 '17 03:08 sebasgarcep

@sebasgarcep actually, I have test it with react-navigation when I found the issue ,but the result is still not smooth enough... :(

Symous avatar Aug 15 '17 05:08 Symous

@Symous Are you running production builds? The difference in performance is huge.

sebasgarcep avatar Aug 15 '17 16:08 sebasgarcep

@Symous I have a work around for this problem. Check out this blog post https://medium.com/@akash_gupta/react-native-how-settimout-saved-my-life-803346bf18a5 if this helps. You can use the deferred rendering of the component in which you are using ListItem as suggested on the blog.

Akshg avatar Sep 11 '17 19:09 Akshg

@sebasgarcep not yet, I just running in the develop mode, will try that later, thanks.

Symous avatar Sep 13 '17 01:09 Symous

@Akshg What about using InteractionManager instead of setTimeout? Have you tried that?

sebasgarcep avatar Sep 13 '17 15:09 sebasgarcep

@sebasgarcep yes i tried InteractionManager but it didn't help. I used like it is shown here https://github.com/brentvatne/run-after-interactions-exp/blob/master/main.js

Akshg avatar Sep 13 '17 17:09 Akshg

@Akshg @sebasgarcep @Symous

I tried using native ListView alongwith 'ListItem' from 'react-native-elements'. And this fixed my lagging and it works pretty awsm. Following is the working code snippet.

<ListView
        style={styles.container}
        dataSource={this.state.dataSource}
        renderRow={(rowdata) => 
          <ListItem
                roundAvatar
                title={`${rowdata.name.first} ${rowdata.name.last}`}
                subtitle={rowdata.email}
                avatar={{ uri: rowdata.picture.thumbnail }}
                containerStyle={{ borderBottomWidth: 0 }}
                rightIcon={{ name: 'phone', type: 'font-awesome', color: '#f50', raised: true}}
                onPressRightIcon={this.callfunction}
              />
        }
        renderSeparator={(sectionId, rowId) => <View key={rowId} style={styles.separator} />}
        renderHeader={() => <Header />}
        renderFooter={() => <Footer />}
        renderSectionHeader={(sectionData) => <SectionHeader {...sectionData} />}
/>

ksrawat avatar Sep 21 '17 03:09 ksrawat

@ksrawat so,we need to download 'react-native-elements' to our app?

Symous avatar Sep 21 '17 03:09 Symous

@Symous yes u need to install 'react-native-elements' https://react-native-training.github.io/react-native-elements/

try to use it with native Listview.

ksrawat avatar Sep 21 '17 17:09 ksrawat

@ksrawat If things work flawlessly in react-native-elements, then there is a performance issue in this library that is worth investigating. I hope I had the time. Maybe someone else?

sebasgarcep avatar Sep 21 '17 21:09 sebasgarcep

NativeBase List will be deprecated, very soon this will be documented So please use React Native's FlatList in place of it You can use ListItem for the necessary styling

SupriyaKalghatgi avatar Nov 08 '17 06:11 SupriyaKalghatgi