Inconsistent behavior on conditional render on mobile
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, react
- Domain
- frontend
Research direction
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.
Written by the indexing model from the issue text.
Description
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?
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from react-grid-layout/react-draggable
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
react-grid-layout/react-draggable#784 · 4 comments · 2 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
react-grid-layout/react-draggable#782 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
react-grid-layout/react-draggable#781 · 1 comment · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
react-grid-layout/react-draggable#780 · 8 comments ·
All issues in react-grid-layout/react-draggable
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
avniproject/avni-client#2135 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bevyengine/bevy-website#2595 ·
-
ecosystem wording
Difficulty 1/5 Under an hour Newbie friendliness 90/100
matrix-org/matrix.org#3649 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vadimdemedes/ink#1029 ·