Skip to content

Commit

Permalink
fix: the crash of scrollToIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
hellohublot committed Jul 2, 2024
1 parent 365a23e commit 6a032da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/PageContentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ export default class PageContentView extends Component<PageContentViewProps> {
},
} = 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);
Expand Down

0 comments on commit 6a032da

Please sign in to comment.