-
Notifications
You must be signed in to change notification settings - Fork 2.7k
layouts文件state状态改变时,在以下情况下会触发pages页面重新 mount #1129
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
Comments
我觉得这个应该是由于 antd 的 Layout 组件是一个 ContextProvider, 而 React 在 // The context might have changed so we need to recalculate it.
if (hasContext) {
invalidateContextProvider(workInProgress, Component, true);
} 导致 children 全部被重绘。再加上 list/_layout 中使用了鉴权路由造成的 Component 重建,最后导致了重新 mount。 一种解决方案就是把 Layout 组件放到 state update 影响不到的地方,比如:
|
@dilidili 布局里用了两个 Layout,拿不出来的,看看后面如果解不了的话只能改成 div自己写了 |
dilidili
pushed a commit
to dilidili/umi
that referenced
this issue
Sep 29, 2018
dilidili
pushed a commit
to dilidili/umi
that referenced
this issue
Oct 8, 2018
dilidili
pushed a commit
to dilidili/umi
that referenced
this issue
Oct 12, 2018
xiaohuoni
added a commit
that referenced
this issue
Oct 15, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
复现条件:
1.layouts中使用 antd 的 Layout组件
2.pages对应目录下有 _layout.tsx 文件
删除 antd 的 Layout组件 或 删除 _layout.tsx 文件,都不会出现此问题
复现demo: https://github.com/SwordsmanYao/kmx-ui-next-platform/tree/issue-layout
操作:
1.进到 http://localhost:8000/list
2.点击‘转换’按钮
结果:
列表被重新加载了
期望:
列表不会重新加载
The text was updated successfully, but these errors were encountered: