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

Updates `DeckSwiper` state when receiving new dataSource #966

Merged
merged 2 commits into from Jun 20, 2017

Conversation

Projects
None yet
2 participants
@mu29
Contributor

mu29 commented Jun 19, 2017

Problem

DeckSwiper did not update even though I put a new dataSource in it.

Solution

componentWillReceiveProps detects the length of a new data source and changes its state.

@mu29

This comment has been minimized.

Contributor

mu29 commented Jun 19, 2017

Conflict fixed! @shivrajkumar

@shivrajkumar shivrajkumar self-assigned this Jun 19, 2017

@shivrajkumar

This comment has been minimized.

Collaborator

shivrajkumar commented Jun 20, 2017

@mu29 Could you also add use-case or code snippet for this. That will be helpfull

@mu29

This comment has been minimized.

Contributor

mu29 commented Jun 20, 2017

Sure.

class TestComponent extends Component {

  ...

  render() {
    <Container>
      <Body>
        <DeckSwiper
          dataSource={ this.state.bookmarks }
          renderItem={ quiz => <Image source={ quiz.src } /> }
        />
      </Body>
      <Footer>
        <FooterTab>
          <Button full onPress={ this.onDeleteBookmark } />
        </FooterTab>
      </Footer>
    </Container>
  )
}

In earlier versions, calling onDeleteBookmark() on these components did not refresh DeckSwiper (even it injects a new dataSource props to DeckSwiper), so the deleted bookmark were remained on the top.

@shivrajkumar shivrajkumar merged commit f868356 into GeekyAnts:master Jun 20, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment