-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Tab 切换的时候组件卸载,导致状态丢失 #4839
Labels
Comments
|
这个可以达到效果 但我们这边的实际场景是 tab 里面是一个比较耗时的操作 (React PDF) |
这个场景的话,可以先用forceRender保持子组件的渲染,然后在业务逻辑里对耗时操作进行类似懒加载(延迟执行?按需执行?)的操作。或者不用forceRender的话,就把状态丢到全局状态管理器里吧,或者状态提升也行。 |
的确复现出来了,我来看下 |
看起来需要对 Tabs 的实现逻辑做比较大的重构 |
已修复 5a9d665 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version of antd-mobile
5.1.0
Operating system and its version
iOS
Browser and its version
Chrome 98.0.4758.80
Sandbox to reproduce
https://codesandbox.io/s/eager-mclean-k1pgc7?file=/src/App.tsx
What happened?
切换 Tab 的时候,Tab Content 渲染内容没有被保留
导致状态丢失,组件重新绘制
正常情况应该是第一次显示 Tab 时渲染内容,切换 Tab 进行只是不可见,DOM仍然需要保留
切换回来的时候将第一次生成的 DOM 重新显示出来
https://codesandbox.io/s/lively-worker-vifynu?file=/index.js
这个是antd的实现,切换 Tab 后 DOM 内容仍然保留
Relevant log output
No response
The text was updated successfully, but these errors were encountered: