patternfly / patternfly/patternfly-react
Resolve inconsistencies when forwarding components
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 862
- フォーク
- 392
- 平均マージ
- 4日 8時間
- マージ済み PR(30日)
- 9
説明
Describe the issue. What is the expected and unexpected behavior?
Sometimes as a user you want to be able to pass in your custom component to render instead of the default element. However the API around this varies wildly per component. For example, these are some components we use in our application that need React Router's Link component:
Button
{/* @ts-ignore */}
<Button component={Link} to={toNewClientScope({ realm })}>
{t("createClientScope")}
</Button>
DropdownItem
<DropdownItem
component={<Link to={toDashboard({ realm })}>{t("realmInfo")}</Link>}
/>
BreadcrumbItem
<BreadcrumbItem
render={(props) => (
<Link {...props} to={toRealmSettings({ realm, tab: "keys" })}>
{t("keys")}
</Link>
)}
/>
As you can see there are already three different ways of forwarding a component to render, and some of them are not able to be written in a type-safe manner.
The expected behavior here would be that this is a single and consistent API that is completely type-safe. For example, Styled Components has a as prop which is made type-safe by the definitions and allows the props to be forwarded and type-checked as well:
import styled from 'styled-components'
const Button = styled.button`
background-color: hotpink;
`
<Button component={Link} to={toNewClientScope({ realm })}>
{t("createClientScope")}
</Button>
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue にリンクされている styled-components の型定義を参照し、Button、DropdownItem、BreadcrumbItem の forwarding API と TypeScript の挙動を比較します。これらのコンポーネントが、カスタムコンポーネントとその props を forwarding するための一貫した type-safe な方法を提供できれば、作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- react, typescript
- 領域
- frontend
- issue の種類
- リファクタリング
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100