From 25dd59a4b53d6ea89e1cb8c670e5f8c91f179cc5 Mon Sep 17 00:00:00 2001 From: Haiyang Zhao Date: Fri, 28 Oct 2016 17:29:07 +0800 Subject: [PATCH] fix the warning when dataSource.length = 1 --- ViewPager.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ViewPager.js b/ViewPager.js index b0709ed..afa193c 100644 --- a/ViewPager.js +++ b/ViewPager.js @@ -279,12 +279,14 @@ var ViewPager = React.createClass({ pagesNum++; // right page - if (this.state.currentPage < pageIDs.length - 1) { - bodyComponents.push(this._getPage(this.state.currentPage + 1)); - pagesNum++; - } else if (this.state.currentPage == pageIDs.length - 1 && this.props.isLoop) { - bodyComponents.push(this._getPage(0, true)); - pagesNum++; + if (pageIDs.length > 1) { + if (this.state.currentPage < pageIDs.length - 1) { + bodyComponents.push(this._getPage(this.state.currentPage + 1)); + pagesNum++; + } else if (this.state.currentPage == pageIDs.length - 1 && this.props.isLoop) { + bodyComponents.push(this._getPage(0, true)); + pagesNum++; + } } }