ant-design / ant-design/pro-components
👑 [需求] 优化ProLayout 渲染时 child 组件的位置跳动问题
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 1.4k
- Avg merge
- 10h 44m
- Merged PRs (30d)
- 3
Description
### 🔩 所属模块或组件
ProLayout
### 🥰 需求描述
目前第一次访问页面都会出现子组件跳动,用户反馈影响体验。 希望用户首次加载进入页面就能够看到最终的ProLayout Style。
### ⛰ 功能需求适用场景
用户首次进入页面
### 🧐 解决方案
root cause 是因为 PageContainerBase 中的 useEffect 使用 setHasPageContainer 更新state, 导致 WrapperContent 组件更新 contentClassName 中的 `${prefixCls}-content-has-page-container` class 导致css改变。
PageContainer 中 PageContainerBase 组件 useEffect 改用为 useLayoutEffect.
### 🚑 其他信息
子组件第一次渲染
**首次渲染**

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

Contributor guide
Research direction
Start in the PageContainer implementation and locate the PageContainerBase component, its useEffect call, and the setHasPageContainer update. Check how this update changes WrapperContent's contentClassName during the first render; done means the initial ProLayout display no longer visibly jumps when the page first loads.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100