Fix ReservationList infinite update loop under React 18/19#2742
Open
mazdak wants to merge 1 commit intowix:masterfrom
Open
Fix ReservationList infinite update loop under React 18/19#2742mazdak wants to merge 1 commit intowix:masterfrom
mazdak wants to merge 1 commit intowix:masterfrom
Conversation
|
We need this |
|
What happened to that? This PR is the only solution to the current problem. we need this solution in production |
|
this didnt work for me but #2713 did |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change fixes a potential infinite update loop in the Agenda’s ReservationList when used with newer React versions (18/19+).
The current implementation of ReservationList.componentDidUpdate uses
prevProps !== this.propsas part of its guard:With React 18/19 and the new architecture, props objects are often recreated on each render. As a result,
prevProps !== this.propscan be true on every update, even when the values have not changed. Combined with setState in componentDidUpdate, this can cause ReservationList to continually update, leading to:What this PR changes
ReservationList.componentDidUpdate is updated to only respond when:
This keeps the original behavior (recomputing reservations when topDay moves or items change) but avoids treating a new props object as a guaranteed change. In practice this:
Impact
I’ve tested this change against a real app using Agenda under React 19 / RN 0.81, where it eliminates the infinite update crash (ReservationList → Agenda) without regressing scrolling behavior.