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: Minimum pledge amount is not correctly rendered #4241

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

apsinghdev
Copy link
Contributor

fixes: #4238

This PR fixes the default value of Minimum funding amount not getting updated bug. With these changes, the value of the Minimum pledge amount is not defaulting to 20 across rerenders.

Screen.Recording.2024-10-22.at.12.38.02.AM.mov

I think it fixes the bug. @frankie567

Copy link

vercel bot commented Oct 21, 2024

@apsinghdev is attempting to deploy a commit to the polar-sh Team on Vercel.

A member of the Team first needs to authorize it.

@apsinghdev apsinghdev force-pushed the fix/min-pledge-amount branch from 06e55ec to 8a4bcfc Compare October 22, 2024 18:37
@reynaldichernando
Copy link
Contributor

I tested this, and it does work.
However, I'm still curious as to why changing the value props doesn't re-render the MoneyInput component.

@apsinghdev apsinghdev force-pushed the fix/min-pledge-amount branch from 8a4bcfc to 9b01a00 Compare December 3, 2024 07:39
@apsinghdev
Copy link
Contributor Author

I tested this, and it does work. However, I'm still curious as to why changing the value props doesn't re-render the MoneyInput component.

By default, the value is assigned to internalValue using useState. So the value is set in the initial render but later on when the value of value changes useState doesn't cause a re-render because of its nature hence we get default value even after updating it. So a simple solution would be to use a useEffect to track the changes in value and keep it in sync with internalValue.

@apsinghdev apsinghdev force-pushed the fix/min-pledge-amount branch from 9b01a00 to ef08293 Compare December 3, 2024 07:50
@apsinghdev
Copy link
Contributor Author

@frankie567 I've fixed and updated this one too.

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.

Minimum pledge amount is not correctly rendered in badge settings
2 participants