question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RecyclerViewBackedScrollView does not render all the rows if it's inside ViewPagerAndroid

See original GitHub issue

A ListView - that is using RecyclerViewBackedScrollView as scroll container - put inside a ViewPagerAndroid will not render all the rows, but just the initial rows.

The problem is that the RecyclerViewBackedScrollView is not updating its internal views since it thinks that the layout pass has not happened. I will post a PR to solve it, I just created this issue to reference it in the code.

  • [ React Native 0.23.1] What’s the version of React Native you’re using?
  • [ Android ] Does this occur on iOS, Android or both?
  • [ Windows ] Are you using Mac, Linux or Windows?
import React, {
  AppRegistry,
  Component,
  StyleSheet,
  Text,
  View,
  ListView,
  ScrollView,
  RecyclerViewBackedScrollView,
  ViewPagerAndroid,
} from 'react-native';

class ListViewTest extends Component {
  constructor(props){
    super(props);

    var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    var rows = [];
    for (var i=0; i<100; i++){
      rows.push(i);
    }

    this.state = {
      dataSource: ds.cloneWithRows(rows),
    };
  }

  renderItem(item){
      return <Text style={{color: '#000000', fontSize: 20, flex: 1, textAlign: 'center'}}>{item}</Text>;
  }

  render() {
    return (
      <View style={styles.container}>
        <ViewPagerAndroid
          initialPage={0}
          style={{flex: 1}}
          >
          <View>
            <ListView
              dataSource={this.state.dataSource}
              renderRow={this.renderItem.bind(this)}
              style={styles.listView}
              pageSize={1}
              initialListSize={10}
              renderScrollComponent={props => {
                //return <ScrollView {...props} />; uncommenting this line it will work as expected
                return <RecyclerViewBackedScrollView {...props} />;
              }}
            />
          </View>
        </ViewPagerAndroid>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
  },
  listView: {
    position: 'absolute',
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
  },
});

AppRegistry.registerComponent('ListViewTest', () => ListViewTest);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
theodoregoldcommented, Dec 3, 2016

@godness84 I was struggling with this for 2 days not understanding why my rows are not rendered. Thank you for posting this.

@mkonicek I am using RecyclerViewBackedScrollView with this package. https://github.com/maolion/mao-rn-android-kit Check this for explanation. https://github.com/maolion/mao-rn-android-kit/issues/5#issuecomment-250371624

0reactions
lackercommented, Dec 15, 2016

It sounds like the solution here is that we will remove RecyclerViewBackedScrollView in react native core and encourage people to use these third party implementations. I’m thus going to close this issue. Thanks everyone for helping out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native - RecyclerViewBackedScrollView not updating
I am trying to use ListView with renderScrollComponent as RecyclerViewBackedScrollView it works only if data already exists which is not ...
Read more >
React.Basic.Native - Pursuit - PureScript
If the user taps to navigate to a new page but the new page is not in this ... Whether this view should...
Read more >
ViewPagerAndroid - React Native
Container that allows to flip left and right between child views. Each child view of the ViewPagerAndroid will be treated as a separate...
Read more >
ListView – React Native | A framework for building native apps ...
Called when all rows have been rendered and the list has been scrolled to within onEndReachedThreshold of the bottom. The native scroll event...
Read more >
types/react-native/index.d.ts - UNPKG
This will generally include most components that you define in your own app. ... Not all fonts have a variant for each of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found