Skip to content

Add multiple style tag to support client components #13

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yanghoxom
Copy link

We will have a case page.tsx is server or client components

This pull can fix these issues (page.tsx is a server component)
ant-design/ant-design#47122
ant-design/ant-design#47104

In this case, the first time only remaining some components, not enough
the second time also only remaining some components, not enough
That's why we need both.

we will have server and client components
@afc163 afc163 requested review from Copilot and MadCcc May 12, 2025 02:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the logic for injecting styles to better support client components by allowing multiple style tags when needed.

  • Changes the type of the inserted flag from boolean to string to compare with the extracted style text.
  • Modifies the insertion check to compare against the current style text rather than a simple truthy value.


useServerInsertedHTML(() => {
const styleText = extractStyle(cache, { plain: true });

if (inserted.current) {
if (inserted.current === styleText) {
Copy link
Preview

Copilot AI May 12, 2025

Choose a reason for hiding this comment

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

Using an empty string as the initial value for 'inserted' can cause the condition to be true when styleText is empty, potentially skipping the intended style insertion. Consider initializing 'inserted' to null or undefined to avoid a conflict with a valid empty styleText.

Copilot uses AI. Check for mistakes.

@afc163
Copy link
Member

afc163 commented May 12, 2025

@MadCcc 有空看看

@KingAmo
Copy link

KingAmo commented May 21, 2025

can confirm it fixed ant-design/ant-design#53736

@MadCcc
Copy link
Member

MadCcc commented May 21, 2025

There may be duplicate style inserted if only judge the styleText is same or not.
But this could simple resolve the problem caused by loading.tsx because there's no antd components when loading.

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.

4 participants