Skip to content

refactor: Use channel to optimize render #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 22, 2023
Merged

refactor: Use channel to optimize render #32

merged 6 commits into from
Mar 22, 2023

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Mar 21, 2023

使用 MessageChannel 使其批量更新在下一帧前,Resize 事件后。从而避免渲染时额外的跳动。需要多看看是否对使用有影响。

ref ant-design/ant-design#41374

@vercel
Copy link

vercel bot commented Mar 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
overflow ❌ Failed (Inspect) Mar 22, 2023 at 2:16AM (UTC)

raf(callback);
} else {
const channel = new MessageChannel();
channel.port1.onmessage = () => callback();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
channel.port1.onmessage = () => callback();
channel.port1.onmessage = callback;

Copy link
Member Author

Choose a reason for hiding this comment

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

TS 会报错,所以包了一下。

Copy link
Member

Choose a reason for hiding this comment

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

soga

@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #32 (af63786) into master (478db39) will decrease coverage by 1.44%.
The diff coverage is 90.32%.

❗ Current head af63786 differs from pull request most recent head 559dbbb. Consider uploading reports for the commit 559dbbb to get more accurate results

@@            Coverage Diff             @@
##           master      #32      +/-   ##
==========================================
- Coverage   99.50%   98.07%   -1.44%     
==========================================
  Files           4        5       +1     
  Lines         203      208       +5     
  Branches       69       68       -1     
==========================================
+ Hits          202      204       +2     
- Misses          1        4       +3     
Impacted Files Coverage Δ
src/hooks/channelUpdate.ts 50.00% <50.00%> (ø)
src/Overflow.tsx 99.30% <100.00%> (ø)
src/hooks/useEffectState.tsx 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zombieJ zombieJ merged commit aa4b5b8 into master Mar 22, 2023
@delete-merged-branch delete-merged-branch bot deleted the opt branch March 22, 2023 02:32
@zombieJ zombieJ mentioned this pull request Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants