Tabs with context provider in between <Tabs> and <Tablist>
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 3.1k
- Fork
- 455
- Merge medio
- 5h 9m
- PR unite (30g)
- 2
Descrizione
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?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non sono indicati file sorgente o test. Inizia riproducendo la struttura DndProvider, Tabs, TabList e TabPanel, quindi esamina come l'avviso conta gli elementi Tab e TabPanel. Il lavoro è completato quando una composizione con il provider per primo viene renderizzata senza l'avviso, mantenendo lo stesso numero di elementi Tab e TabPanel.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- frontend
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100