Skip to content

refactor(react-runtime): dedupe hook callbacks#2350

Merged
Yradex merged 2 commits intolynx-family:mainfrom
colinaaa:codex/hook-callback-dedup
Mar 30, 2026
Merged

refactor(react-runtime): dedupe hook callbacks#2350
Yradex merged 2 commits intolynx-family:mainfrom
colinaaa:codex/hook-callback-dedup

Conversation

@colinaaa
Copy link
Copy Markdown
Collaborator

@colinaaa colinaaa commented Mar 18, 2026

This slices the hook callback dedup optimization out of the bundle-size work.

Changes:

  • Share the render hook wrapper in packages/react/runtime/src/lifecycle/isRendering.ts
  • Share the timing hook wrapper in packages/react/runtime/src/lynx/performance.ts
  • Remove the now-unused preact VNode type import

Validation:

  • git diff --check

Commit: e9c7554
issue: #17

Summary by CodeRabbit

  • Refactor
    • Internal code consolidation and cleanup for improved maintainability.

@colinaaa colinaaa requested review from HuJean, Yradex and hzy as code owners March 18, 2026 14:04
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 18, 2026

⚠️ No Changeset found

Latest commit: e320ccb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

The PR refactors duplicate hook callback logic in React runtime lifecycle handling by consolidating RENDER_COMPONENT and ROOT hook callbacks into shared utility functions, eliminating code duplication while preserving existing behavior and call order.

Changes

Cohort / File(s) Summary
Lifecycle Hook Consolidation
packages/react/runtime/src/lifecycle/isRendering.ts, packages/react/runtime/src/lynx/performance.ts
Refactors duplicate inline hook callbacks for RENDER_COMPONENT and ROOT hooks into shared handler functions. Replaces per-hook type annotations with generic rest parameters, guards handler invocations, and removes unused imports, eliminating code duplication while preserving execution order and behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

framework:React

Suggested reviewers

  • Yradex
  • hzy

Poem

🐰 Hooks once doubled, now consolidated,
Shared handlers keep the flow delegated,
Code deduped, but logic stays the same,
Cleaner branches win the refactor game! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: deduplication of hook callbacks across two files to reduce code duplication.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9c7554eda

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/react/runtime/src/lynx/performance.ts
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 72 untouched benchmarks
⏩ 21 skipped benchmarks1


Comparing colinaaa:codex/hook-callback-dedup (e320ccb) with main (95fff27)2

Open in CodSpeed

Footnotes

  1. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (9193711) during the generation of this report, so 95fff27 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Mar 18, 2026

Web Explorer

#8503 Bundle Size — 728.6KiB (0%).

e320ccb(current) vs 9193711 main#8502(baseline)

Bundle metrics  Change 1 change
                 Current
#8503
     Baseline
#8502
No change  Initial JS 43.3KiB 43.3KiB
No change  Initial CSS 2.16KiB 2.16KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 10 10
Change  Modules 148(-0.67%) 149
No change  Duplicate Modules 11 11
No change  Duplicate Code 34.69% 34.69%
No change  Packages 3 3
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#8503
     Baseline
#8502
No change  Other 384.4KiB 384.4KiB
No change  JS 342.04KiB 342.04KiB
No change  CSS 2.16KiB 2.16KiB

Bundle analysis reportBranch colinaaa:codex/hook-callback-ded...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Mar 28, 2026

React MTF Example

#59 Bundle Size — 207.39KiB (-0.04%).

e320ccb(current) vs 9193711 main#58(baseline)

Bundle metrics  Change 1 change
                 Current
#59
     Baseline
#58
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 46.39% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 174 174
No change  Duplicate Modules 68 68
No change  Duplicate Code 46.09% 46.09%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#59
     Baseline
#58
No change  IMG 111.23KiB 111.23KiB
Improvement  Other 96.16KiB (-0.08%) 96.24KiB

Bundle analysis reportBranch colinaaa:codex/hook-callback-ded...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Mar 28, 2026

React Example

#6925 Bundle Size — 237.82KiB (-0.03%).

e320ccb(current) vs 9193711 main#6924(baseline)

Bundle metrics  Change 1 change
                 Current
#6925
     Baseline
#6924
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 38.73% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 180 180
No change  Duplicate Modules 71 71
No change  Duplicate Code 46.4% 46.4%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#6925
     Baseline
#6924
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 92.06KiB (-0.08%) 92.13KiB

Bundle analysis reportBranch colinaaa:codex/hook-callback-ded...Project dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
Collaborator

@Yradex Yradex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看过了。这个改动是纯粹的 hook callback 去重:调用顺序没变,副作用也还是先 old hook 再 set/helper,没有引入新的语义分叉。CI 也全绿。

@Yradex Yradex merged commit 495ad36 into lynx-family:main Mar 30, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants