-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
double renders with react-beautiful-dnd #496
Comments
We are finalizing a diff now for Concurrent Mode support that reduces double renders in more situations. Hopefully that may help this example. |
How dose the Concurrent Mode will reduces double renders? Can u explain it in term of source code of the recoil for me ? Thank u very much! |
Has there been any update on this issue? We're facing the same problem. The only workaround I've found so far is to duplicate the recoil state with some dependent state within my component (using a hook like what is described here https://dev.to/bmingles/usedependentstate-react-usestate-hook-with-dependencies-29fj), but it's making a real mess of our code to have to capture 2 separate states like that. |
@cornwe19 - Are you still having issues when using the latest experimental React with Concurrent Mode enabled? |
hi~ same rerender problem with recoil@0.1.3 |
I'm seeing this issue too where recoil seems to be re-rendering before and after the atom state update which results in some list items briefly rendering their original order before the final order when dropping an item. I've even tried using react 18 with concurrent mode by using the new Here's a sandbox: https://codesandbox.io/s/react-beautiful-dnd-recoil-flash-bug-58scv?file=/src/App.js Ignoring the initial log, if you drop an item, it logs 'rendering recoil' before and after rendering the list whereas with the useState version, it only logs after. |
github/facebookexperimental/Recoil#496 Fix styled-components bug github/styled-components/styled-components#3564
On further investigation, this bug is related to #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. |
* tim-survey-builder: (26 commits) add readme Question types render own Inspector properties. Update parts atom to include type config. Enable importing absolute paths. Restructure folders. Recoil devtools. Mobile navbar views. Move items with animation. Dnd lock axis. Improve mobile responsive for frame + single type. Refactor DND to avoid unneeded part rerenders. Short answer integration Start adding mobile responsiveness. Fix recoil not working in ios. Fix storybook startup issue due to new Framework imports. Fix ios bug where any component using react-tabulator eg. admin/forms/list won't show list items. see ngduc/react-tabulator#215 Add ios build Add dragndrop for canvas Reinstalling storybook Load editor's json into builder. Builder can update editor source on clicking save. Update DND. Update placeholder type. Enable builder in editor without blowing up. Fix circular imports. Refactor recoil state. Load json and save source. Fix error in engine.js when using strict mode. Add toolbar to generate source. Refactor to make it easier to add new question types. Update single item styles Reduce storybook startup time. Update dnd for single items. Fix recoil + rbd bug github/facebookexperimental/Recoil#496 Fix styled-components bug github/styled-components/styled-components#3564 Merge in Minh's short question code. Add dnd to single items. EditProperty can auto render with complex paths Modify single items in canvas and inspector ...
Closing as this feature is now enabled by default. |
I am familiar with #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
anduseState
: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
The text was updated successfully, but these errors were encountered: