Skip to content
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

👑 [需求] 优化ProLayout 渲染时 child 组件的位置跳动问题 #8194

Open
asuiah opened this issue Feb 27, 2024 · 3 comments · May be fixed by #8894
Open

👑 [需求] 优化ProLayout 渲染时 child 组件的位置跳动问题 #8194

asuiah opened this issue Feb 27, 2024 · 3 comments · May be fixed by #8894

Comments

@asuiah
Copy link

asuiah commented Feb 27, 2024

🔩 所属模块或组件

ProLayout

🥰 需求描述

目前第一次访问页面都会出现子组件跳动,用户反馈影响体验。 希望用户首次加载进入页面就能够看到最终的ProLayout Style。

⛰ 功能需求适用场景

用户首次进入页面

🧐 解决方案

root cause 是因为 PageContainerBase 中的 useEffect 使用 setHasPageContainer 更新state, 导致 WrapperContent 组件更新 contentClassName 中的 ${prefixCls}-content-has-page-container class 导致css改变。

PageContainer 中 PageContainerBase 组件 useEffect 改用为 useLayoutEffect.

🚑 其他信息

子组件第一次渲染
首次渲染
image

useEffect 执行setHasPageContainer 再次渲染,添加 ${prefixCls}-content-has-page-container
image

@wenruiq
Copy link

wenruiq commented Apr 16, 2024

+1

@lifuhh
Copy link

lifuhh commented Apr 18, 2024

+1 experiencing layout shift issue as well

@anuoua
Copy link

anuoua commented Jul 18, 2024

+1

drizzlesconsin added a commit to drizzlesconsin/pro-components that referenced this issue Nov 27, 2024
@drizzlesconsin drizzlesconsin linked a pull request Nov 27, 2024 that will close this issue
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 a pull request may close this issue.

4 participants