Skip to content

Conversation

@mazdak
Copy link

@mazdak mazdak commented Nov 17, 2025

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.props as 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.props can 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:

  • Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
  • A component stack pointing at ReservationList → Agenda.

What this PR changes

ReservationList.componentDidUpdate is updated to only respond when:

  • The visible topDay actually changes (by value), or
  • The items reference changes while topDay stays the same.

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:

  • Prevents unnecessary updateReservations calls on every render.
  • Avoids “Maximum update depth exceeded” loops under React 18/19/new architecture.

Impact

  • No public API changes.
  • No behavior change for callers that update topDay or items explicitly.
  • Improves compatibility with React 18/19 and React Native new architecture, where props identity is not stable.

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.

@feri-irawan
Copy link

We need this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants