From 6a032da99e11bd3d7c240a626c9cde2c5180beca Mon Sep 17 00:00:00 2001 From: hublot Date: Tue, 2 Jul 2024 08:11:28 +0800 Subject: [PATCH] fix: the crash of scrollToIndex --- package.json | 2 +- src/PageContentView.tsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 84ab4c3..c9bf2f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/react-native-tab-page-view", - "version": "1.0.4", + "version": "1.0.5", "description": "React Native Tab Page View", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/PageContentView.tsx b/src/PageContentView.tsx index 62188f3..5ee8140 100644 --- a/src/PageContentView.tsx +++ b/src/PageContentView.tsx @@ -91,7 +91,11 @@ export default class PageContentView extends Component { }, } = event; const reloadWidth = PixelRatio.roundToNearestPixel(width); - if (reloadWidth !== this.state.scrollViewWidth && reloadWidth > 0) { + if ( + reloadWidth !== this.state.scrollViewWidth && + reloadWidth > 0 && + (this?.props?.data?.length ?? 0) > 0 + ) { this._scrollViewWidthValue.setValue(reloadWidth); this.setState({ scrollViewWidth: reloadWidth }, () => { this?.scrollView?.current?.reloadScrollContainerWidth?.(reloadWidth);