Skip to content

Conversation

@PeachScript
Copy link
Member

@PeachScript PeachScript commented Jul 9, 2025

Image 组件的 placeholder 不做条件式渲染,和 img 一样通过 display 来控制,使得 Image DOM 快照恢复并水合时不会失败

失败原因是快照时的 placeholder 不一定存在(比如图片已经加载好了)但后续水合时一定存在(因为初始态就是 loaded: false

Summary by CodeRabbit

  • 优化
    • 改进了图片组件的占位符显示逻辑,提升了加载体验并减少了服务端渲染时的警告。

@coderabbitai
Copy link

coderabbitai bot commented Jul 9, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap is excluded by !**/*.snap
  • src/components/image-uploader/tests/__snapshots__/image-uploader.test.tsx.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

本次更改调整了 Image 组件内部占位符的渲染逻辑。占位符现在始终渲染(只要存在),并通过内联样式在图片加载后隐藏。增加了 suppressHydrationWarning 属性以避免服务端渲染时的 hydration 警告。图片元素本身未做修改。

Changes

文件/路径 变更摘要
src/components/image/image.tsx 调整占位符渲染逻辑,增加样式控制与 hydration 抑制属性

Poem

🐇
图片未现时,兔子藏身,
占位符静静守护在身旁。
加载一到,悄然隐形,
Hydration 警告也不再惊。
代码世界,变化无声,
兔子为你把守每一程。

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2025

Preview is ready

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jul 9, 2025
@dosubot dosubot bot added the refactor label Jul 9, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 9, 2025

npm i https://pkg.pr.new/ant-design/ant-design-mobile/antd-mobile@6910

commit: ece8ea3

return (
<>
{!loaded && props.placeholder}
{props.placeholder && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样每个图片都会多一个 div,感觉不太好

@codecov
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.79%. Comparing base (2fd292d) to head (ece8ea3).
⚠️ Report is 33 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6910      +/-   ##
==========================================
- Coverage   92.80%   92.79%   -0.02%     
==========================================
  Files         336      336              
  Lines        7246     7248       +2     
  Branches     1786     1825      +39     
==========================================
+ Hits         6725     6726       +1     
- Misses        513      514       +1     
  Partials        8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PeachScript PeachScript marked this pull request as draft July 9, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants