Tabs with context provider in between <Tabs> and <Tablist>
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 3.1k
- Forks
- 455
- Ø Merge
- 5 Std. 9 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
Hi all,
I'm working on creating a drag and drop version of react tabs using react-dnd.
React dnd requires a DndProvider context to be wrapped around any draggable/droppable objects. I'm currently trying to do something like this:
function DndTabs({data}) {
// (...Some functions that require the DndContext here...)
return (
<TabList>
{Object.keys(data).map(tabId => {
<Tab key={tabId}> tabId </Tab>
})}
</TabList>
)
}
function DndContainer({data}) {
return (
<DndProvider>
<DndTabs data={data} />
</DndProvider>
)
}
function TabHolder() {
return (
<Tabs>
<DndContainer data={data} />
{Object.keys(data).map(tabId => {
<TabPanel key={tabId}> tabId </TabPanel>
})}
</Tabs>
)
}
This is throwing the
Warning: Failed prop type: There should be an equal number of 'Tab' and 'TabPanel' in 'UncontrolledTabs' error, even though the actual rendered HTML should have tablist and tabpanels as siblings with an equal number of Tab and TabPanel elements.
I tried following the advice in #253 (calling the react component as a function instead of letting react render it) but this causes issues with the DndContext because functions that require the context to exist need to render after the Context itself renders.
Is there any structure that I can use that will make this work, following the additional constraint that the Provider for the Dnd Context needs to appear/render before the actual Tabs?
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
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
Es wird keine Quelldatei und kein Test genannt. Beginne damit, die Struktur aus DndProvider, Tabs, TabList und TabPanel nachzubilden, und untersuche dann, wie die Warnung Tab- und TabPanel-Elemente zählt. Als erledigt gilt die Aufgabe, wenn eine Provider-zuerst-Komposition ohne die Warnung gerendert wird und dabei gleich viele Tab- und TabPanel-Elemente erhalten bleiben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, react
- Bereich
- frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100