-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Lazy load ViewShot #5517
Lazy load ViewShot #5517
Conversation
|
@@ -33,12 +37,12 @@ export const PlaceholderCanvas = React.forwardRef<PlaceholderCanvasRef, {}>( | |||
|
|||
React.useImperativeHandle(ref, () => ({ | |||
// @ts-ignore this library doesn't have types | |||
capture: viewshotRef.current.capture, | |||
capture: viewshotRef.current?.capture, |
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.
are we ok with this method being null in some cases? should we instead wrap to make it a noop?
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.
i tweaked it like this so it will show up as possibly being undefined 3b220f6
(#5517)
im going to see if i can just get rid of that ts-ignore though, i think there actually is a type for this
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.
okay yea, this feels nicer 1006d70
(#5517) (plus this to only import the type, oops 18462ad)
a14804d
to
1006d70
Compare
* origin/main: Use Inter variable font (#5540) Fix name in `feature_request.yml` (#5542) Fix sticky offset, gear color (#5537) Move email test to root tests dir (#5527) revamp issue templates, add new arch template (#5532) use PressableScale for animation (#5541) Rework native autocomplete (#5521) Pinned posts (#5055) Remove Segment (#5518) Fix alignment of cancel button on search (#5520) [Share Extension] Support on Android for sharing videos to app (#5466) Ignore bogus onScroll values (#5499) add podcasts to spotify embeds (#5514) Tweak font size of "Write your reply" (#5513) Lazy load ViewShot (#5517) [Share Extension] Support images/movies from other apps like iMessage (#5515)
Why
Now that we are able to, we should lazy-load
ViewShot
, since it saves us almost 80kbHow
Just using
React.lazy
andReact.Suspense
. Extremely basic for the QR code dialog, we just useReact.Suspense
to show the spinner untilview-shot
has loaded.For signup, we won't actually use
React.Suspense
, because we don't want the user to get blocked from signing up for any reason. However, we will try to make sure it's ready to go by the time the user gets to that screen.import()
forview-shot
Test Plan
Go through an account creation, you should still get one of the "new" default avatars. Also verify that QR codes still work.