Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

React-Native ScrollView lost position on setState

$
0
0

I need to change state of a row within ScrollView (the same in ListView) but using setState of component makes scroll reset its position to top.

<ScrollView        {...this.panResponder.panHandlers}        bounces={false}        onScroll={() => {          this.scrollIsScrolling = true;        }}        onTouchEnd={() => {          this.scrollIsScrolling = false;        }}        onMomentumScrollEnd={() => {          this.scrollIsScrolling = false;        }}        scrollEnabled={this.state.scrollEnabled}        removeClippedSubviews={false}        enableEmptySections        style={styles.listView}>        {this.props.settings.map((setting, i) => {          return (<IntegrationSlideupCell              key={i}              title={setting.title}              selected={this.state.selectedSetting === i}              selectedGradient={this.props.integration.selectedGradient}              onPress={() => {                this.setState({ selectedSetting: i });              }}            />          );        })}</ScrollView>

UPD: Removing custom panHandlers, onScroll, onTouchEnd, onMomentumScrollEnd handlers and other props makes no difference. The only thing that causes it setState.


Viewing all articles
Browse latest Browse all 16552

Trending Articles