-
Notifications
You must be signed in to change notification settings - Fork 11.5k
fix: Prevent Booker Component Re-renders on Input Keystroke #21429
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
Conversation
|
@panphora is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cubic found 1 issue across 4 files. Review it in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
|
|
||
| return ( | ||
| <FormBuilderField className="mb-4" field={{ ...field, hidden }} readOnly={readOnly} key={index} /> | ||
| <MemoizedField className="mb-4" field={{ ...field, hidden }} readOnly={readOnly} key={index} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spreading field into a new object on every render creates a new reference, which defeats React.memo’s shallow comparison and causes the component to re-render on every keystroke – exactly the problem this PR tries to solve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! I just sent an update that fixes this by:
- Creating memoized components with React.memo
- Passing individual props (field, hidden, readOnly) separately
- This allows React.memo to correctly detect unchanged props and prevent re-renders
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (05/21/25)1 reviewer was added to this PR based on Keith Williams's automation. "Add community label" took an action on this PR • (05/21/25)1 label was added to this PR based on Keith Williams's automation. |
|
To address the issues mentioned, I created a dedicated memoized component for form fields that passes individual props rather than creating a new object |
|
now we have some failing tests! 🙏 |
|
All set! |
|
This PR is being marked as stale due to inactivity. |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
This PR fixes an issue where every keystroke in the name or email input caused the entire Booker component to re-render, causing a laggy input performance.
Files Modified:
packages/features/bookings/Booker/components/BookEventForm/MemoizedField.tsx(new file)packages/features/bookings/Booker/components/BookEventForm/BookingFields.tsxpackages/features/bookings/Booker/components/hooks/useBookingForm.tsHow It Works
The fix isolates form field rendering by memoizing components and values. When a user types in an input field, only that specific field re-renders instead of the entire Booker component, resulting in better performance during form interactions.
This is a minimal and targeted fix that addresses the re-rendering issue without making major architectural changes to the codebase.
Mandatory Tasks (DO NOT REMOVE)
Summary by cubic
Fixed laggy input in the Booker form by preventing the whole component from re-rendering on each keystroke.