question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

double renders with react-beautiful-dnd

See original GitHub issue

I am familiar with https://github.com/facebookexperimental/Recoil/issues/307 rendering components with recoil twice on initialization.

But I am also getting double renders when I use https://github.com/atlassian/react-beautiful-dnd

Here is my test case [1] https://github.com/jedierikb/recoil-beautiful-dnd

& here is the line you can toggle to switch between useRecoilState and useState: https://github.com/jedierikb/recoil-beautiful-dnd/blob/master/src/App.js#L64

In the console you will note there are two renders after every drop operation when using useRecoilState.

I am not knowledgeable about what is happening under the hood in either library to possibly trigger the double rendering, but since it is a popular library I thought this issue might be of interest.

[1] adapted from one of their provided examples https://codesandbox.io/s/k260nyxq9v

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
drarmstrcommented, Jul 27, 2020

We are finalizing a diff now for Concurrent Mode support that reduces double renders in more situations. Hopefully that may help this example.

2reactions
timiscodingcommented, Aug 26, 2021

On further investigation, this bug is related to https://github.com/facebookexperimental/Recoil/issues/1076 and already fixed in 0.4.0 but disabled by default behind the ‘recoil_early_rendering_2021’ flag. I made a fork of the package and re-enabled it as @timiscoding/recoil.

I have recreated the OP’s test case https://codesandbox.io/s/double-render-recoil-bug-2tmmq?file=/src/index.js and if you use my forked package, the problem is gone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi List Drag and Drop With react-beautiful-dnd, Immer, and ...
We'll explore how to use react-beautiful-dnd to create multi-list drag and drops. ... DragDropContext specifies the area in which you can render the...
Read more >
How to Add Drag and Drop in React with React Beautiful DnD
Step 3: Saving list order after reordering items with React Beautiful DnD. When we move our items, they stay where they land for...
Read more >
Adding drag-and-drop functionality with react-beautiful-dnd
In it, we create a droppable container and map over our DataElements , then render a Draggable element for each one. What is...
Read more >
ReactJS - Page re-renders but one component stays the same ...
I think the problem lies in this line in the constructor : this.state = { items: props.answers, };. Setting items like this in...
Read more >
IMPLEMENTING BEAUTIFUL DRAG & DROP : REACT ...
React -Beautiful-DND is one of the most user friendly and easy to use ... The react app will be rendered in browser locally...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found