-
Notifications
You must be signed in to change notification settings - Fork 3
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 slowness in delegate page #180
Conversation
Deploying delegit with Cloudflare Pages
|
The main issue was
If you type in the input now, it's instant. Before it took a sec for the text to appear. |
aliceKeyPair.publicKey, | ||
'Sr25519', | ||
aliceKeyPair.sign, | ||
const aliceKeyPair = useMemo(() => derive('//Alice'), [derive]) |
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.
Not sure I understand this... derive (line 14) already uses useMemo
. Why to reuse it?
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.
Because we don't need to derive every single render if derive
doesn't change. So the aliceKeyPair
will be derived once for all. Also I just memoize / useCallback everything at this point. Spending an hour to find the one function that makes everything slow is more time consuming than bluntly memoizing every single const IMHO. I used to do this in all my apps, chose not to be annoying for Delegit, and it bit us all the same. The experience of using the delegate page just got much much better thanks to this.
Thanks for the review, and sorry for the 1000 oversights of logs etc 😅 |
closes #151