Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
Solves the issue of state messing up when parent component calls setState [ref leecade/react-native-swiper#569]
  • Loading branch information
rauljurado620 committed Feb 23, 2019
1 parent dfc4168 commit 09f891f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export default class extends Component {

componentWillReceiveProps (nextProps) {
if (!nextProps.autoplay && this.autoplayTimer) clearTimeout(this.autoplayTimer)
if (nextProps.index === this.props.index) return;
this.setState(this.initState(nextProps, this.props.index !== nextProps.index))
}

Expand Down

0 comments on commit 09f891f

Please sign in to comment.