perf: initialize pager hook resources once - #1124
Open
OskarEichler wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
perf: initialize pager hook resources once. Fixes #1107.
Compatibility / observable changes
No public API change. pagesAmount remains an initialization-only input; subsequent rerenders no longer allocate discarded page arrays or Animated.Values.
Implementation
usePagerView recreates initial page arrays and Animated.Values on each render. The change is kept independent from the other source-review fixes. This contribution is AI-assisted.
Test Plan
bun run typescript,bun run lint(zero errors; 25 existing example warnings),bun run prepare, andgit diff --checkpass../gradlew assembleDebug --max-workers=4), iOS Simulator Release (xcodebuild, signing disabled), and both production Metro bundles pass with its RN 0.85.3 dependencies.No checked-in test files were added or modified. The existing Jest suite contains one TODO and no executed tests; focused external diagnostics provide the behavioral checks.
Prerequisites and reproduction
See #1107 for the baseline, reproduction and proposed fix.
Checklist
Downstream RN 0.87.1 verification
The combined 9.0.2 consumer artifact is pinned at
35a43b89b9e658c926a647a5b8bf9c7863e73771. Immutable install and byte comparison of all 66 non-metadata files pass. Both Android Debug variants, both iOS Debug Simulator variants, four production Metro bundles, 13 web builds, four extension builds and app lint pass. The first Android attempt encountered a concurrent web-output replacement during Gradle input hashing; serial rerun passed. The upstream iOS example also launches and renders its home screen. This does not cover physical devices or the complete Maestro interaction matrix.