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: don't refresh main component on first page load #1985

Merged
merged 6 commits into from
May 16, 2023
Merged

Fix: don't refresh main component on first page load #1985

merged 6 commits into from
May 16, 2023

Conversation

katspaugh
Copy link
Member

@katspaugh katspaugh commented May 12, 2023

What it solves

Resolves #1980

This was a regression from #1968.

How this PR fixes it

The router.query is initially empty. This is to avoid hydration issues with the static build which doesn't have any query params by definition.

On safe-specific routes, router.query.safe then gets populated with the value from the URL, thus going from undefined to a string. This causes the main page component to re-render due to the key prop.

I've added a hook that only changes the key if the previous value was set.

@katspaugh katspaugh requested a review from iamacook May 12, 2023 14:46
@github-actions
Copy link

github-actions bot commented May 12, 2023

Branch preview

✅ Deploy successful!

https://safekey--walletweb.review-wallet-web.5afe.dev

@github-actions
Copy link

github-actions bot commented May 12, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

src/pages/_app.tsx Outdated Show resolved Hide resolved
@francovenica
Copy link
Contributor

I got 1 call after refreshing normally and then 1 call in the first 15 secs polling, but after that every 15 secs I always got 2 calls for balances:

In the gif I reload manually, clear the storage and wait 15 secs twice, clearing the storage every time
calls

katspaugh and others added 2 commits May 15, 2023 13:48
* Fix: useAsync should clear data if no promise

* Rm async from useLoadBalances
@katspaugh
Copy link
Member Author

@francovenica fixed 👍

@francovenica
Copy link
Contributor

LGTM now.

@katspaugh katspaugh merged commit 68dd66d into dev May 16, 2023
@katspaugh katspaugh deleted the safekey branch May 16, 2023 08:25
@github-actions github-actions bot locked and limited conversation to collaborators May 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Two balances requests
3 participants