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

1 second delay in setState , when flatlist is used #15480

Closed
vishnuc opened this issue Aug 13, 2017 · 6 comments
Closed

1 second delay in setState , when flatlist is used #15480

vishnuc opened this issue Aug 13, 2017 · 6 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@vishnuc
Copy link

vishnuc commented Aug 13, 2017

So I have component like below

 return (
      <View>
        <View
          style={!this.state.showSearchBar && styles.hidden}
        >
          <Header>
            <View>
              <Item >
                <Icon name="ios-search" />
                <Input placeholder="Search" />
              </Item>
              <Button
                onPress={this.searchBarButton}
              >
                <Text>Search</Text>
              </Button>
            </View>
          </Header>
        </View>

        <View
          style={this.state.showSearchBar && styles.hidden}
        >
          <Header ref={"button"}>
            <Button onPress={() => this.searchBarButton()} transparent>
              <Icon name="search" style={styles.bigblue} />
            </Button>
          </Header>
        </View>

<FlatList style={{zIndex: 0,minHeight:'100%'}}
				ref={ref => {
					this.listRef = ref;
				}}
				extraData={this.state}
				data={this.state.data}
				onRefresh={this.onRefresh}
				refreshing={this.state.refreshing}
				renderItem={this._renderItem}
				onEndReached={this.onEnd}
				onEndReachedThreshold={0.5}
				ListHeaderComponent={this.headerMessage}
				ListFooterComponent={this.footerMessage}
				ListEmptyComponent={this.empty}
			/>


      </View>
    );
  }

When I click on button I basically set state so I am hiding and showing search bar with search icon

 searchBarButton() {
    this.setState({ showSearchBar: !this.state.showSearchBar });
  }

and style

   hidden: {
    height: 0,
    width: 0,
    opacity: 0
  }

So basically this works very smooth and fast when my scene is just with header , But when I add flatlist , there is 1 second delay between toggle.But if I remove flat list its again fast.

@iamawebgeek
Copy link

iamawebgeek commented Aug 14, 2017

Are you using the state inside flat list? If no, remove it from extraData and check if it has got better

@vishnuc
Copy link
Author

vishnuc commented Aug 14, 2017 via email

@iamawebgeek
Copy link

Is your renderItem component pure? Also in __DEV__ mode there may be some slow performance, try to uncheck it in development settings and reload the bundle

@vishnuc
Copy link
Author

vishnuc commented Aug 14, 2017 via email

@oakis
Copy link

oakis commented Sep 30, 2017

I had this problem in DEV but not in production. Thanks @iamawebgeek

@stale
Copy link

stale bot commented Nov 29, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 29, 2017
@stale stale bot closed this as completed Dec 6, 2017
@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants