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

ViewPagerAndroid renders empty dynamically added views after upgrade from v0.42.3 to v0.44.2 #14296

Closed
SandraLum opened this issue Jun 2, 2017 · 4 comments · Fixed by callstack/react-native-pager-view#2
Labels
Resolution: Locked This issue was locked by the bot. Resolution: PR Submitted A pull request with a fix has been provided.

Comments

@SandraLum
Copy link

SandraLum commented Jun 2, 2017

Description

I have an array to store children views for ViewPagerAndroid, as I dynamically append views to the array, I am expecting to see newly added views to be rendered as I swipe through the pager, it was working however after the upgrade from v0.42.3 to v0.44.2, it is currently rendering empty views.

Reproduction Steps and Sample Code

 addPage() {
    let pages = this.state.pages
    pages.push(<View style={{ flex: 1 }}><Text>{'New Page'}</Text></View>)
    this.setState({ pages: pages })
  }

  render() {
    return (
      <ViewPagerAndroid ref='viewPager'
        {...this.props}
        style={{ flex: 1 }}>
        {pages}
      </ViewPagerAndroid>
    ) }

Solution

Going through the upgrades changes, it seems to call for a re-render upon layout change on the container.

I am doing a bad hack for now is to adjust the layout so as to trick a render to occur. Modifying the style with marginBottom of 1px seems subtle enough for me.

       <ViewPagerAndroid ref='viewPager'
        {...this.props}
        style={[{flex: 1}, {marginBottom: pages.length % 2 == 0 ? 1 : 0 }]}>
        {pages}
      </ViewPagerAndroid>

Additional Information

  • React Native version: v0.44.2
  • Platform: Android
  • Development Operating System: Windows 10
@ricardofbarros
Copy link

ricardofbarros commented Jun 3, 2017

I'm also experiencing this, so I also have a hack in place to trigger a re-render so the view shows.

I also encountered this issue while using (react-native-community/react-native-tab-view)[https://github.com/react-native-community/react-native-tab-view] when using the lazy option.

@bood
Copy link

bood commented Jun 5, 2017

Should be similar to #13463, see my comment there for a work around fix.

@itinance
Copy link
Contributor

We could build a simple workaround this way:

#13463 (comment)

@hramos
Copy link
Contributor

hramos commented Aug 31, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Aug 31, 2017
@hramos hramos closed this as completed Aug 31, 2017
@hramos hramos added the Resolution: PR Submitted A pull request with a fix has been provided. label Jul 19, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Aug 31, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot. Resolution: PR Submitted A pull request with a fix has been provided.
Projects
None yet
7 participants
@hramos @bood @itinance @SandraLum @ricardofbarros @react-native-bot and others