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
Root cause of state issues #7066
Labels
Milestone
Comments
Any update on this? |
Also facing this issue. Update. |
I am also facing this issue :/ any leads? |
I had the same problem syncing events with a backend, the solution I found is to have a local state of the events and not sync it with the calls to the backend, at the moment I think it is the best solution. |
The root cause has been solved in v6.1.3. See:
@parisholley , thanks for making this tracking ticket. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After running into some state issues myself, I started digging through the library to figure out what the underlying issue could be. I believe the same problem is impacting the following issues:
The root cause appears to be this code here:
fullcalendar/packages/common/src/option-change-handlers.ts
Lines 15 to 48 in f55ba69
In particular, two problems:
As noted in the comment, the diff'ing algorithm does not currently support passing in the
events
prop, it can only diffeventSources
. As a result, every time a component with<FullCalendar />
is re-rendered, the event store is destroyed and recreated.Due to one, it would appear the solution would be as simple as switching to
eventSources
, however the problem is the diffing logic does a strict equality check, and if the object isn't the same memory reference as the previous render, it is also destroyed and recreated. so if a user started a drag, the drag'd element is referring to an event instance that was part of the old/destroyed store and the re-render can't tell you are dragging the same thing on refresh.To solve for fullcalendar/fullcalendar-react#2, I am able to work around by implementing the following:
useRef
will guarantee that each render will get the same event source object and pass the equality check, and I only update it between renders if the JSON serialization changes.It isn't clear the best way to implement a fix given that async functions/fetches can be part of the equation, and depending on the use cases, a full hash of the event data may be a performance hit.
The text was updated successfully, but these errors were encountered: