diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 36e5f3640671fe..ec03040dc8b88a 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -374,6 +374,15 @@ class VirtualizedList extends React.PureComponent { return; } + if (this._scrollRef.scrollTo == null) { + console.warn( + 'No scrollTo method provided. This may be because you have two nested ' + + 'VirtualizedLists with the same orientation, or because you are ' + + 'using a custom component that does not implement scrollTo.', + ); + return; + } + this._scrollRef.scrollTo( this.props.horizontal ? {x: offset, animated} : {y: offset, animated}, ); @@ -437,6 +446,15 @@ class VirtualizedList extends React.PureComponent { return; } + if (this._scrollRef.scrollTo == null) { + console.warn( + 'No scrollTo method provided. This may be because you have two nested ' + + 'VirtualizedLists with the same orientation, or because you are ' + + 'using a custom component that does not implement scrollTo.', + ); + return; + } + this._scrollRef.scrollTo( horizontal ? {x: offset, animated} : {y: offset, animated}, ); @@ -478,6 +496,15 @@ class VirtualizedList extends React.PureComponent { return; } + if (this._scrollRef.scrollTo == null) { + console.warn( + 'No scrollTo method provided. This may be because you have two nested ' + + 'VirtualizedLists with the same orientation, or because you are ' + + 'using a custom component that does not implement scrollTo.', + ); + return; + } + this._scrollRef.scrollTo( this.props.horizontal ? {x: offset, animated} : {y: offset, animated}, );