patternfly / patternfly/patternfly-react
Resolve inconsistencies when forwarding components
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 862
- Forks
- 392
- Ø Merge
- 4 T. 8 Std.
- Gemergte PRs (30 T.)
- 9
Beschreibung
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>
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Vergleiche die Forwarding-APIs und das TypeScript-Verhalten von Button, DropdownItem und BreadcrumbItem und verwende dabei die im Issue verlinkten Type-Definitionen von styled-components als Referenz. Die Arbeit ist abgeschlossen, wenn diese Komponenten eine einheitliche, typsichere Möglichkeit bieten, eine benutzerdefinierte Komponente und deren Props weiterzuleiten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- react, typescript
- Bereich
- frontend
- Issue-Typ
- Refactoring
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100