leecade / leecade/react-native-swiper

Android - Dynamic Pages Index Problems

Open
#303 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

When dynamically loading pages in componentDidMount, if the new array of pages has more than what was set in the constructor you cannot scroll to these pages. The following will reproduce the bug:

  constructor(props) {
    super(props)

    this.state = {
      posts: [{
        id: 'FOO'
      },
      {
        id: 'BAR'
      }]
    }
  }

  componentDidMount() {
    this.setState({
      posts: [{
        id: 'FOO'
      },
      {
        id: 'BAR'
      },
      {
        id: 'FOOBAR'
      },
      {
        id: 'BARFOO'
      }]
    })
  }

This works fine:

  constructor(props) {
    super(props)

    this.state = {
      posts: [{
        id: 'FOO'
      },
      {
        id: 'BAR'
      }]
    }
  }

  componentDidMount() {
    this.setState({
      posts: [{
        id: 'FOOBAR'
      },
      {
        id: 'BARFOO'
      }]
    })
  }

Using React Native 0.38

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported React Native 0.38 reproduction, comparing the two componentDidMount cases where pages are replaced or appended. Trace how the swiper builds and updates its page indexes after state changes, then verify that newly appended pages can be reached by scrolling without breaking the existing pages.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.