reactjs / reactjs/react.dev

Extracting Emotion Styles for a Specific Component Using Ref

オープン
#7,165 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
11.8k
フォーク
7.9k
平均マージ
1日 11時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リポジトリのファイル、テスト、エントリポイントについては何も言及されていません。まず、@emotion/styled がドキュメントの head に style タグを挿入する方法と、ref がレンダリングされた1つのコンポーネントのスタイルを特定するかどうかを調査します。すべてのタグを走査せずにそれらのスタイルへアクセスする方法について、確認済みで文書化された回答が得られれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react
領域
frontend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。