Skip to content

Conversation

mu29
Copy link

@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 fix/refresh-deck-swiper branch 2 times, most recently from 9cda7e3 to 6022dde Compare June 19, 2017 13:43
@mu29
Copy link
Author

mu29 commented Jun 19, 2017

Conflict fixed! @shivrajkumar

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

shivrajkumar commented Jun 20, 2017

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

@mu29
Copy link
Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants