Skip to content

Commit

Permalink
Skip renders every second
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottkember committed Nov 25, 2024
1 parent c63c1d5 commit 03896bd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
15 changes: 13 additions & 2 deletions lib/commonjs/ReactNativeZoomableView.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/commonjs/ReactNativeZoomableView.js.map

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions lib/module/ReactNativeZoomableView.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/module/ReactNativeZoomableView.js.map

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/ReactNativeZoomableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,18 @@ class ReactNativeZoomableView extends Component<
// to avoid messing up calculations, especially ones that are done right after
// the component transitions from hidden to visible.
if (!x && !y && !width && !height) return;

// If these values are all the same, don't re-set them in state
// this way we don't re-render
if (
this.state.originalWidth === width &&
this.state.originalHeight === height &&
this.state.originalPageX === x &&
this.state.originalPageY === y
) {
return;
}

this.setState({
originalWidth: width,
originalHeight: height,
Expand Down

0 comments on commit 03896bd

Please sign in to comment.