Inconsistent behavior on conditional render on mobile
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, react
- Ambito
- frontend
Direzione di ricerca
Start by reproducing the conditional state change around the Draggable component, comparing the original wrapper with the individually wrapped Baz 1 and Baz 2 examples. Determine whether the behavior comes from React conditional rendering or react-draggable, and document the conditions that reproduce the inconsistency; the issue names no repository files or tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
If I have a component that looks like this:
const Foo = () => {
const [state, setState] = useState(null);
const renderBar = () => {
if (state) { return (<div>Baz 1</div>); }
return (<div>Baz 2</div>);
}
return (
<Draggable>
{renderBar()}
</Draggable>
);
}
Then there is a chance that when either Baz 1 or Baz 2 gets rendered, it's not draggable. I suspect that this has to do with the state changing and Draggable only applying to whichever gets the initial render.
This observation comes from about 2 hours of debugging... for context, in my project, state is actually passed into the Foo component and can be set outside of Foo. Baz 2 is a table of a lot of components, whose slow rendering may or may not have contributed to this inconsistent behavior.
I resolved the inconsistency by individually wrapping Baz1 and Baz2 like this:
const Foo = (props) => {
const [state, setState] = useState(null);
const renderBar = () => {
if (state) { return (
<Draggable>
<div>Baz 1</div>
</Draggable>
); }
return (
<Draggable>
<div>Baz 2</div>
</Draggable>
);
}
return renderBar();
}
Is this inconsistency specific to react-draggable or is it an expected behavior of react?
- Lingua principale
- JavaScript
- Stelle
- 9.3k
- Fork
- 1k
- Merge medio
- 2g 16h
- PR unite (30g)
- 5
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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.
Altre issue di react-grid-layout/react-draggable
-
bug ready-for-agent
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
react-grid-layout/react-draggable#822 · 2 commenti ·
-
bug needs-info
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
react-grid-layout/react-draggable#782 · 2 commenti ·
-
bug needs-info
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
react-grid-layout/react-draggable#772 · 1 commento ·
-
error in react 19Apertabug ready-for-agent
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
react-grid-layout/react-draggable#771 · 14 commenti · 31 reazioni ·
-
enhancement ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
react-grid-layout/react-draggable#762 · 1 commento ·
Tutte le issue di react-grid-layout/react-draggable
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
szTheory/exifcleaner#383 ·
I maintainer di solito rispondono entro 1 giorno
-
Frontend good first issue P2-medium UI UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Deepak3699/Ai_Mentor#179 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python-visualization/folium#2293 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue type: bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
medusajs/medusa#17127 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
keyxmakerx/Chronicle#1061 ·
I maintainer di solito rispondono entro 1 giorno