Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentWillReceiveProps(nextProps) {
const { index } = nextProps;
if (typeof index === 'number' && index !== this.props.index) {
if (process.env.NODE_ENV !== 'production') {
checkIndexBounds(nextProps);
}
this.setIndexCurrent(index);
this.setState({
// If true, we are going to change the children. We shoudn't animate it.
displaySameSlide: getDisplaySameSlide(this.props, nextProps),
indexLatest: index,
});
}
}
componentWillReceiveProps(nextProps) {
const { index } = nextProps;
if (typeof index === 'number' && index !== this.props.index) {
if (process.env.NODE_ENV !== 'production') {
checkIndexBounds(nextProps);
}
// If true, we are going to change the children. We shoudn't animate it.
const displaySameSlide = getDisplaySameSlide(this.props, nextProps);
this.setState(
{
displaySameSlide,
indexLatest: index,
},
() => {
if (this.scrollViewNode) {
this.scrollViewNode.scrollTo({
x: this.state.viewWidth * index,
y: 0,
animated: this.props.animateTransitions && !displaySameSlide,
});
}
},
);
componentWillReceiveProps(nextProps) {
const { index, animateTransitions } = nextProps;
if (typeof index === 'number' && index !== this.props.index) {
if (process.env.NODE_ENV !== 'production') {
checkIndexBounds(nextProps);
}
// If true, we are going to change the children. We shoudn't animate it.
const displaySameSlide = getDisplaySameSlide(this.props, nextProps);
if (animateTransitions && !displaySameSlide) {
this.setState(
{
indexLatest: index,
},
() => {
this.animateIndexCurrent(index);
},
);
} else {
this.setState({
indexLatest: index,
indexCurrent: new Animated.Value(index),
});
}
UNSAFE_componentWillReceiveProps(nextProps) {
const { index } = nextProps;
if (typeof index === 'number' && index !== this.props.index) {
if (process.env.NODE_ENV !== 'production') {
checkIndexBounds(nextProps);
}
this.setIndexCurrent(index);
this.setState({
// If true, we are going to change the children. We shoudn't animate it.
displaySameSlide: getDisplaySameSlide(this.props, nextProps),
indexLatest: index,
});
}
}