Skip to content

chore: bump react-hook-form, @hookform/resolvers, yup#18677

Closed
Lemonexe wants to merge 3 commits intodevelopfrom
bump-hookform+resolvers+yup
Closed

chore: bump react-hook-form, @hookform/resolvers, yup#18677
Lemonexe wants to merge 3 commits intodevelopfrom
bump-hookform+resolvers+yup

Conversation

@Lemonexe
Copy link
Copy Markdown
Contributor

@Lemonexe Lemonexe commented May 1, 2025

Description

  • 47208a5 Bump react-hook-form and related packages (because they're QA'd together).
  • d7af0fe Fix infinite render loop only in tests in mobile trading form, but this also enhances the UX slightly – don't reset form if you choose the same asset 🙂
    • 736ae5a not needed, but do the same UX tweak for fiat currency selection

Related Issue

Resolve #18090

Screenshots

Mobile trading form: don't reset amounts when asset or fiat currency is changed to the same one:
mobile trading form reset.webm

--

🔍🖥️ Suite web test results: View in Currents

🔍🖥️ Suite desktop test results: View in Currents

🔍🖥️ Suite native android test results: View in Currents

Copy link
Copy Markdown
Contributor Author

@Lemonexe Lemonexe May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solve TS error at L76 (string | undefined not assignable to string for path, signature)

The problem arose when bumping @hookform/resolvers + react-hook-form, and then bumping yup did not help.
It took me a while to realize that the former two are not at fault, it's yup that was insufficiently typed (in both versions I tried!), and react-hook-form merely tightened its types to catch that.

@Lemonexe Lemonexe marked this pull request as ready for review May 1, 2025 06:57
@Lemonexe Lemonexe requested review from a team as code owners May 1, 2025 06:57
@Lemonexe Lemonexe marked this pull request as draft May 1, 2025 16:31
@Lemonexe Lemonexe force-pushed the bump-hookform+resolvers+yup branch from 07e156d to 736ae5a Compare May 2, 2025 07:09

if (asset?.networkId !== prevNetworkId.current) {
prevNetworkId.current = asset?.networkId;
setValue('cryptoValue', undefined, { shouldValidate: true });
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix an infinite render loop, that only manifested in tests (the app worked fine)

@Lemonexe Lemonexe requested a review from jbazant May 2, 2025 07:19
@Lemonexe Lemonexe marked this pull request as ready for review May 2, 2025 07:26
@Lemonexe Lemonexe force-pushed the bump-hookform+resolvers+yup branch from 736ae5a to cfd9920 Compare May 2, 2025 12:40
Copy link
Copy Markdown
Contributor

@jbazant jbazant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new behaviour is strange. I have no idea whats going on. The solution is probably to use same useRef with previous value of asset as you prosed with fiatCurrency.

case 'asset': {
if (asset?.networkId !== prevNetworkId.current) {
prevNetworkId.current = asset?.networkId;
setValue('cryptoValue', undefined, { shouldValidate: true });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Moving this setValue inside the if is not correct. Now it does not clear value if you change asset e.g. from Ethereum to 1Inch (or anything on same network)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right! I hadn't thought about multiple assets on the same network, thanks.
In that case I shall find the real cause for the infinite render loop, and fix with keeping current behavior.

@Lemonexe Lemonexe closed this May 2, 2025
@Lemonexe Lemonexe deleted the bump-hookform+resolvers+yup branch May 2, 2025 13:14
@Lemonexe
Copy link
Copy Markdown
Contributor Author

Lemonexe commented May 2, 2025

Closed because I needed to rename the branch.
Having pluses in branch name is what most likely cause connect popup build consistently crashing.

I renamed it via github UI, I hoped it would link this PR to new branch name, but I guess github does not support that 🤷

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.

Bump react-hook-form & @hookform/resolvers

2 participants