reactjs / reactjs/react.dev

Extracting Emotion Styles for a Specific Component Using Ref

未關閉
#7,165 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
JavaScript
星號
11.8k
分支
7.9k
平均合併
1 天 11 小時
30 天內合併 PR
11

描述

In a React application using @emotion/styled, I need to extract the styles generated for a specific component rendered in the DOM, based on a reference (ref). The goal is to capture the <style> tags injected by Emotion that are related to the component currently referenced, without having to loop through all <style> tags in the DOM.

When using @emotion/styled, styles are dynamically injected into the of the document. These styles are global and are not automatically scoped to specific components in a way that makes it straightforward to extract styles for just one component.

Question:-
Is there a way to directly access the <style> tags generated by Emotion for a specific component using a ref?

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

未提及任何儲存庫檔案、測試或進入點。首先調查 @emotion/styled 如何將 style 標籤注入文件的 head,以及 ref 是否能識別某個已渲染元件的樣式;只有在確認並記錄了無需掃描每個標籤即可存取這些樣式的方法後,才算完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript, react
領域
frontend
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
20/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。