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

Updates `DeckSwiper` state when receiving new dataSource #966

Merged
merged 2 commits into from Jun 20, 2017

Conversation

@mu29
Copy link
Contributor

@mu29 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 mu29 force-pushed the mu29:fix/refresh-deck-swiper branch 2 times, most recently from 9cda7e3 to 6022dde Jun 19, 2017
@mu29
Copy link
Contributor Author

@mu29 mu29 commented Jun 19, 2017

Conflict fixed! @shivrajkumar

@shivrajkumar shivrajkumar self-assigned this Jun 19, 2017
@shivrajkumar
Copy link
Collaborator

@shivrajkumar shivrajkumar commented Jun 20, 2017

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

@mu29
Copy link
Contributor Author

@mu29 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
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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.