Skip to content
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

fix: memoized otp input and added example for using onOTPFilled #2497

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tewarig
Copy link
Contributor

@tewarig tewarig commented Jan 27, 2025

Description

This PR fixes the issue with the OTPInput component where the onOTPFilled callback was causing infinite re-renders.
https://stackblitz.com/edit/react-hsrtdxhg?file=App.js

To avoid re-renders, we can wrap OTPInput in React.memo. I have implemented this. Additionally, the function passed to onOTPFilled should be wrapped in useCallback. I have added an example for this in the documentation.

Changes

Additional Information

Component Checklist

  • Update Component Status Page
  • Perform Manual Testing in Other Browsers
  • Add KitchenSink Story
  • Add Interaction Tests (if applicable)
  • Add changeset

Copy link

changeset-bot bot commented Jan 27, 2025

🦋 Changeset detected

Latest commit: 960c115

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@razorpay/blade Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 27, 2025

✅ PR title follows Conventional Commits specification.

@tewarig tewarig changed the title chore: memoized otp input and added example for using onOTPFilled fix: memoized otp input and added example for using onOTPFilled Jan 27, 2025
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 960c115:

Sandbox Source
razorpay/blade: basic Configuration

@rzpcibot
Copy link
Collaborator

rzpcibot commented Jan 27, 2025

Bundle Size Report

Updated Components
Status Component Base Size (kb) Current Size (kb) Diff
OTPInput 30.332 30.339 +0.007 KB

Generated by 🚫 dangerJS against 960c115

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