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

fix: nprogress always pending in custom react pages #1793

Merged
merged 1 commit into from
Jul 30, 2023

Conversation

PeachScript
Copy link
Member

🤔 这个变动的性质是?/ What is the nature of this change?

  • 新特性提交 / New feature
  • bug 修复 / Fix bug
  • 样式优化 / Style optimization
  • 代码风格优化 / Code style optimization
  • 性能优化 / Performance optimization
  • 构建优化 / Build optimization
  • 网站、文档、Demo 改进 / Website, documentation, demo improvements
  • 重构代码或样式 / Refactor code or style
  • 测试相关 / Test related
  • 其他 / Other

🔗 相关 Issue / Related Issue

Close #1750

💡 需求背景和解决方案 / Background or solution

修复启用 nprogress 时,打开自定义 React 页面进度条不会完成的 bug,原因是之前仅对 Markdown 异步路由的加载状态做了捕获

新的解决方案是借助 Suspense 的 fallback 组件(也就是 Umi 的 loading 组件)来设置加载状态,dumi 总是会内置一个空白 loading 来处理加载逻辑,如果用户有配置 loading 时,dumi 的内置 loading 则会包在用户的外面,不影响原有功能

这个方案相比原方案的好处是:

  1. 不局限于 Markdown 路由,而是针对所有异步路由生效(修复原始 issue)
  2. fallback 组件 mount 时开始加载,unmount 时完成加载,时机上比监听 history 更简洁
  3. 再次访问已经完成异步加载的页面时不会再展示 loading

📝 更新日志 / Changelog

Language Changelog
🇺🇸 English Fix nprogress always pending in custom react pages
🇨🇳 Chinese 修复自定义 React 页面中的 nprogress 始终处于加载态的问题

@vercel
Copy link

vercel bot commented Jul 28, 2023

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

Name Status Preview Updated (UTC)
dumi ✅ Ready (Inspect) Visit Preview Jul 28, 2023 11:11am

@PeachScript PeachScript merged commit 8b8ca50 into master Jul 30, 2023
9 checks passed
@PeachScript PeachScript deleted the hotfix/custom-page-nprogress branch July 30, 2023 07:41
@MadCcc
Copy link
Contributor

MadCcc commented Aug 2, 2023

要不要考虑一下 transition 的情况?比如 antd 官网就是希望不展示 fallback 但是展示 nprogress 的。

@PeachScript
Copy link
Member Author

@MadCcc transition 是指?antd 官网不是有使用 loading 组件么,它就是利用 fallback 展示的

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.

bug: 点击切换返回首页(自定义页面),nprogress 无法关闭
2 participants