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 摘要。