refactor: share callback-ref observation between hooks#765
Open
thebuilder wants to merge 17 commits into
Open
Conversation
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
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
useInViewanduseOnInViewonto one private callback-ref observer coreuseInViewattachment commituseInsertionEffectwhen available; React 17 retains render-time callback publication so synchronous fallback reattachment sees the latest callbackuseInViewstate resets in the owning hook and use passive effects during SSRinitialInViewas an initial-only option before the first observer notificationuseInViewfrom 1.3 to 1.36 kB anduseOnInViewfrom 1.1 to 1.12 kBCloses #758.
Bundle sizes
InView: 1.36 / 1.5 kBuseInView: 1.35 / 1.36 kBuseOnInView: 1.11 / 1.12 kBobserve: 775 / 900 BVerification
corepack pnpm exec vitest run --coverage— 96 tests passed across the Node and Chromium projectscorepack pnpm tsccorepack pnpm exec biome check .corepack pnpm build— tsup, attw, publint, and size-limit passedcorepack pnpm run compat:packed -- 17— packed React 17 consumer build passed